diff options
-rwxr-xr-x | emacs.org | 59 |
1 files changed, 23 insertions, 36 deletions
@@ -102,7 +102,8 @@ Request the following packages: gptel beacon ement - mu4e-alert)) + mu4e-alert + pass)) #+end_src ** Installation & activation Set ~package-archives~, and install packages @@ -245,41 +246,26 @@ Fonts and basic appearance settings for each device #+begin_src emacs-lisp (require 'password-store) - (defun thanos/get-pass () - "Get password entry." - (interactive) - (let* ((entry (ivy-read "Search for: " (password-store-list)))) - (when entry - (condition-case err - (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/edit-pass () - "Edit password entry." - (interactive) - (let* ((entry (ivy-read "Search for: " (password-store-list)))) - (when entry - (password-store-edit entry)))) + (defun thanos/pass-action (action) + "Select password entry to perform ACTION." + (let ((entry (ivy-read "Search: " (password-store-list)))) + (funcall action entry))) - (defun thanos/generate-pass () - "Generate password entry." + (defun thanos/pass-auto-type (entry) + "Autotype Password ENTRY." (interactive) - (let* ((entry (ivy-read "Generate: " (password-store-list)))) - (when entry - (password-store-generate entry (+ 20 (random 20))) - (password-store-edit entry) - (insert (format "\nuser:%s" username)) - (server-edit)))) + (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)) + (let ((ivy-height 100)) (unwind-protect (with-selected-frame (make-frame '((name . "thanos/emacs-launcher") @@ -289,12 +275,13 @@ Fonts and basic appearance settings for each device (internal-border-width . 10) (width . 80) (height . 11))) - (let ((choice (completing-read "Choose an action: " '("GET" "EDIT" "GENERATE")))) - (let ((action (pcase choice - ("GET" #'thanos/get-pass) - ("EDIT" #'thanos/edit-pass) - ("GENERATE" #'thanos/generate-pass)))) - (funcall action)) + (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)))))) #+end_src ** Keybindings |