[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[STUMP] Tips on how I am using StumpWM

From: Jean Louis
Subject: [STUMP] Tips on how I am using StumpWM
Date: Mon, 4 Mar 2019 00:38:38 +0100
User-agent: Mutt/1.10.1 (2018-07-13)


I am user of StumpWM, I would like to share some
tips with you.

The idea is on using the X clipboard and
forwarding it straight to various programs.

I have the PostgreSQL database with all
contacts. Whenever I am in terminal or any
application where a name or email address appear,
I can mark the email address with mouse or keys,
and then press C-t u

(define-key *root-map* (kbd "u") "exec cf-open-emacs-for-xclip.lisp")

The program is not really useful for everybody,
but it shows the idea.


(defun main ()
  (let* ((my-string (read-xclip))
         (my-string (string-trim '(#\" #\Newline) my-string)))
    (if my-string
        (shell (format nil "emacsclient -c -s 
/home/data1/protected/tmp/emacs1001/server -e \"(cf-search \\\"~A\\\")\"" 
      (progn (play-fail)
             (notify "Nothing found")))


The database is accessible by various means, in my
case GNU Emacs is opening and giving me list of
available contacts for specific email address or

Another example of using the X clipboard are those
spam and phishing emails. In my case I am using
mutt. Pressing h is to view headers. First line
could show something like:

Received: from (

Then marking the IP number with the mouse and
pressing C-t m in my case is finding quickly the
abuse email address.

(define-key *root-map* (kbd "m") "exec find-abuse-email.lisp")

In terminal it is copied back with Shift-Insert
and email body with full headers is quickly
forwarded to the abuse email address. The speed in
getting the abuse email helped to block so many
phishing attempts. I wrote this with CLISP. It is
just a concept, and surely it can be done much
simpler. This is few years old, and it worked most
of times to find the abuse email, and copy it back
into clipboard. If somebody wish to get it
working, I am willing to help.

;;; This piece of software is reading the clipboard input, when you
;;; get spam email with the mutt, or other email program, you may open
;;; the full headers and find the IP address, something like
;;;, you would mark the email address with the mouse,
;;; and call this script, if you bind it to some key, for example with
;;; alt-ctrl-m, and script will find the abuse email address. You then
;;; forward email to the abuse email address to complain about the
;;; spam. More about us


(defun read-xclip-abuse nil
  (let ((command (concatenate 'string
                              "xclip -out | xargs whois | grep -i abuse | grep 
@ | head -1")))
    (ignore-errors (with-open-stream (str (ext:make-pipe-input-stream command))
      (read-line str)))))

(defun find-email (str)
  (let* ((my-list (regexp:regexp-split " " str))
         (my-email (find-if (lambda (x) (search "@" x)) my-list)))
    (if my-email
      (progn (ext:shell (format nil "echo ~a | xclip -in" my-email))
             (notify (format nil "Abuse email: ~a" my-email))

(defun main nil
  (let ((my-string (read-xclip-abuse)))
    (if my-string
      (find-email my-string)
      (progn (play-fail)
             (notify (format nil "Email not found")))))


Another example is that I like quick keyboard
shortcuts to send a voice mail or record a voice

(define-key *root-map* (kbd "V") "exec voice-mail.lisp")
(define-key *root-map* (kbd "M-v") "exec record-voice-note.lisp")

voice-mail.lisp as concept:


(defparameter *my-tmp-directory* "/home/data1/protected/tmp/")
(defparameter *my-snd-format* ".ogg") ;; .ogg or others?

(defun voice-prepare ()
  (let* ((filename (timestamp-filename))
         (filename-path (concatenate 'string *my-tmp-directory* filename 
         (body-path (concatenate 'string filename-path ".txt"))
         (body-text (format nil "Voice message from Mr. Jean Louis is attached: 
~A~A" filename *my-snd-format*))
         (command-1 (voice-record-command filename-path))
         (command-2 (format nil "echo ~A > ~A" body-text body-path))
         (xterm-1 (format nil "xterm -e ~A" command-1))
         (xterm-2 (format nil "xterm -e mutt -a ~A -i ~A -s \"Voice message by 
Mr. Jean Louis: ~A~A\"" filename-path body-path filename *my-snd-format*)))
    (shell command-2)
    (shell xterm-1)
    (shell xterm-2)))


record-voice-note.lisp as concept:


(setf *sound-recordings-dir* "/home/data1/protected/Media/Sound/Recordings/")

(defparameter *my-snd-format* ".ogg") ;; .ogg or others?

(defun record-voice-note ()
  (let* ((filename (timestamp-filename))
         (year (substring filename 0 4))
         (month (substring filename 5 7))
         (day (substring filename 8 10))
         (date (substring filename 0 10))
         (filename-dir (concatenate 'string *sound-recordings-dir* year "/" 
month "/" date "/"))
         (filename-path (concatenate 'string filename-dir filename 
         (command-1 (voice-record-command filename-path))
         (xterm-1 (format nil "xterm -e ~A" command-1))
         (rox-open (format nil "rox \"~A\"" filename-dir)))
    (ensure-directories-exist filename-path :verbose t)
    (shell xterm-1)
    (shell rox-open)))


Another example is using GNU Emacs to complete any
form in web browsers, or entering text anywhere
back into the clipboard.

(define-key *root-map* (kbd "y") "exec emacs-everywhere.lisp")


(defparameter *emacs* "emacs-client-x")
(defparameter *tmp-dir* "/home/data1/protected/tmp/emacs-everywhere/")
(ensure-directories-exist *tmp-dir*)

(defun tmp-filename ()
  (concatenate 'string *tmp-dir* (timestamp-filename) ".txt"))

(defun emacs-tmp-filename (tmp-filename)
  (let ((command (format nil "~A ~A" *emacs* (tmp-filename))))

(let ((tmp-filename (tmp-filename)))
  (shell (emacs-tmp-filename tmp-filename))
  (if (probe-file tmp-filename)
      (shell (format nil "xclip -selection clipboard -in '~A'" tmp-filename))
      (shell "xclip -out"))))

Those are concepts, they work on my side. If
somebody needs the pieces, I will send it. I am
sure many of them can be done in simpler manner,
even by just using shell.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]