From e9b82d9f8ab139ea7455913b6b2cbcede3371232 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Thu, 20 Jul 2023 22:35:13 +0300 Subject: emacs: Add Pass Launcher --- emacs.org | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) (limited to 'emacs.org') diff --git a/emacs.org b/emacs.org index c888777..65f9751 100755 --- a/emacs.org +++ b/emacs.org @@ -241,13 +241,44 @@ Fonts and basic appearance settings for each device (setq counsel-describe-variable-function #'helpful-variable) #+end_src * Pass -** Misc Functions +** Pass Launcher #+begin_src emacs-lisp - (defun smtp-get-pass () + (defun thanos/pass () (interactive) - "get password for smtp" - (insert - (password-store-get-field "fastmail.com/thanosapollo@fastmail.com" "smtp"))) + (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.1 && xdotool getactivewindow type '%s' && xdotool getactivewindow key Tab && xdotool getactivewindow type '%s'" user pass) + (format "sleep 0.1 && xdotool getactivewindow type 'thanosapollo' && xdotool getactivewindow key Tab && xdotool getactivewindow type '%s'" pass)))))))) + + (defun thanos/edit-pass () + (interactive) + (let* ((entry (ivy-read "Search for: " (password-store-list)))) + (when entry + (password-store-edit entry)))) + + (defun thanos/pass-launcher () + (interactive) + (let* ((choice (completing-read "Choose an action: " '("GET" "EDIT"))) + (ivy-height 100)) + (with-selected-frame + (make-frame '((name . "thanos/emacs-launcher") + (minibuffer . only) + (fullscreen . 0) + (undecorated . t) + (internal-border-width . 10) + (width . 80) + (height . 11))) + (unwind-protect + (if (equal choice "get") + (thanos/pass) + (thanos/edit-pass)) + (delete-frame))))) #+end_src ** Keybindings #+begin_src emacs-lisp -- cgit v1.2.3