summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2023-08-03 23:08:41 +0300
committerThanos Apollo <[email protected]>2023-08-03 23:08:41 +0300
commit227387facae15eba67d75bb7e9848705a3cdb2b0 (patch)
treec9b87147315950c56558a0e964fd85b8bfa57af2
parent55b6e99c91b5fc1c766546ab264689c24d2a4977 (diff)
emacs: Update password launcher
-rwxr-xr-xemacs.org60
1 files changed, 26 insertions, 34 deletions
diff --git a/emacs.org b/emacs.org
index 9051629..40e26e4 100755
--- a/emacs.org
+++ b/emacs.org
@@ -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