stumpwm-devel
[Top][All Lists]
Advanced

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

Re: [STUMP] Tips on how I am using StumpWM


From: Dany Haddad
Subject: Re: [STUMP] Tips on how I am using StumpWM
Date: Sun, 3 Mar 2019 18:53:46 -0600

Awesome! I have something similar but for sending code snippets to a repl for 
evaluation. Useful for some python data science stuff some times :)


> On Mar 3, 2019, at 5:38 PM, Jean Louis <address@hidden> wrote:
> 
> Hello,
> 
> 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.
> 
> (load 
> "/home/data1/protected/Programming/git/RCDBusiness/lib/lisp/utilities.lisp")
> 
> (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\\\")\"" 
> my-string))
>      (progn (play-fail)
>             (notify "Nothing found")))
>    (exit)))
> 
> (main)
> 
> 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
> names.
> 
> 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 cz.webasyst.net (cz.webasyst.net
>        [::ffff:193.161.85.10]
> 
> 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
> ;;; 85.185.244.101, 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 http://www.rcdwealth.com
> 
> (load 
> "/home/data1/protected/Programming/git/RCDBusiness/lib/lisp/utilities.lisp")
> 
> (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))
>             (play-win))
>      (play-fail))))
> 
> (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")))))
>  (exit))
> 
> (main)
> 
> 
> Another example is that I like quick keyboard
> shortcuts to send a voice mail or record a voice
> note.
> 
> (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:
> ===========================
> 
> (load 
> #"/home/data1/protected/Programming/git/RCDBusiness/lib/lisp/date-time.lisp")
> (load 
> #"/home/data1/protected/Programming/git/RCDBusiness/lib/lisp/soundtools.lisp")
> 
> (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 
> *my-snd-format*))
>         (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)))
> 
> (voice-prepare)
> 
> 
> 
> record-voice-note.lisp as concept:
> ==================================
> 
> (load 
> #"/home/data1/protected/Programming/git/RCDBusiness/lib/lisp/configure-system.lisp")
> (load 
> #"/home/data1/protected/Programming/git/RCDBusiness/lib/lisp/connect.lisp")
> (load 
> #"/home/data1/protected/Programming/git/RCDBusiness/lib/lisp/date-time.lisp")
> (load 
> #"/home/data1/protected/Programming/git/RCDBusiness/lib/lisp/cf-tools.lisp")
> (load 
> #"/home/data1/protected/Programming/git/RCDBusiness/lib/lisp/soundtools.lisp")
> 
> (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 
> *my-snd-format*))
>         (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)))
> 
> (record-voice-note)
> 
> 
> 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")
> 
> emacs-everywhere.lisp:
> ======================
> 
> (load 
> "/home/data1/protected/Programming/git/RCDBusiness/lib/lisp/date-time.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))))
>    command))
> 
> (let ((tmp-filename (tmp-filename)))
>  (shell (emacs-tmp-filename tmp-filename))
>  (if (probe-file tmp-filename)
>    (progn
>      (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.
> 
> Jean
> 
> _______________________________________________
> Stumpwm-devel mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/stumpwm-devel



reply via email to

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