diff options
-rwxr-xr-x | emacs.org | 60 |
1 files changed, 26 insertions, 34 deletions
@@ -211,43 +211,35 @@ Generate a random password between 20 and 40 characters #+begin_src emacs-lisp (require 'password-store) - (defun thanos/pass-action (action) - "Select password entry to perform ACTION." - (let ((entry (ivy-read "Search: " (password-store-list)))) - (funcall action entry))) - - (defun thanos/pass-auto-type (entry) - "Autotype Password ENTRY." - (interactive) - (let ((user (password-store-get-field entry "user")) - (pass (password-store-get entry))) - (start-process-shell-command - "xdotool" nil - (if user - (format "sleep 0.3 && xdotool getactivewindow type '%s' && xdotool getactivewindow key Tab && xdotool getactivewindow type '%s'" user pass) - (format "sleep 0.3 && xdotool getactivewindow type 'thanosapollo' && xdotool getactivewindow key Tab && xdotool getactivewindow type '%s'" pass))))) - (defun thanos/pass-launcher () "Launch Emacs as a front-end for pass." (interactive) - (let ((ivy-height 100)) - (unwind-protect - (with-selected-frame - (make-frame '((name . "thanos/emacs-launcher") - (minibuffer . only) - (fullscreen . 0) - (undecorated . t) - (internal-border-width . 10) - (width . 80) - (height . 11))) - (let* ((choice (completing-read "Choose an action: " '("AUTO" "COPY" "EDIT" "GENERATE"))) - (action (pcase choice - ("AUTO" #'thanos/pass-auto-type) - ("COPY" #'password-store-copy) - ("EDIT" #'password-store-edit) - ("GENERATE" (password-store-generate (+ 20 (random 20))))))) - (thanos/pass-action action) - (delete-frame)))))) + (cl-flet ((pass-autotype (entry) + (let ((user (password-store-get-field entry "user")) + (pass (password-store-get entry))) + (start-process-shell-command + "xdotool" nil + (if user + (format "sleep 0.3 && xdotool getactivewindow type '%s' && xdotool getactivewindow key Tab && xdotool getactivewindow type '%s'" user pass) + (format "sleep 0.3 && xdotool getactivewindow type 'thanosapollo' && xdotool getactivewindow key Tab && xdotool getactivewindow type '%s'" pass)))))) + (let ((ivy-height 100)) + (unwind-protect + (with-selected-frame + (make-frame '((name . "thanos/pass-launcher") + (minibuffer . only) + (fullscreen . 0) + (undecorated . t) + (internal-border-width . 10) + (width . 80) + (height . 11))) + (let* ((choice (completing-read "Choose an action: " '("AUTO" "COPY" "EDIT" "GENERATE"))) + (action (pcase choice + ("AUTO" #'pass-autotype) + ("COPY" #'password-store-copy) + ("EDIT" #'password-store-edit) + ("GENERATE" #'password-store-generate)))) + (funcall action (ivy-read "Search: " (password-store-list))) + (delete-frame))))))) #+end_src ** Keybindings #+begin_src emacs-lisp |