about summary refs log tree commit diff
path: root/init
diff options
context:
space:
mode:
Diffstat (limited to 'init')
-rw-r--r--init/functions.el20
-rw-r--r--init/nixos.el5
2 files changed, 24 insertions, 1 deletions
diff --git a/init/functions.el b/init/functions.el
index 07411396b27d..5ed9a06fd6fb 100644
--- a/init/functions.el
+++ b/init/functions.el
@@ -170,4 +170,24 @@ Including indent-buffer, which should not be called automatically on save."
                            (when (string= event "finished\n")
                              (message "%s process finished." process))))))))
 
+(defun ivy-password-store (&optional password-store-dir)
+  "Custom version of password-store integration with ivy that
+  actually uses the GPG agent correctly."
+
+  (interactive)
+  (ivy-read "Copy password of entry: "
+            (password-store-list (or password-store-dir (password-store-dir)))
+            :require-match t
+            :keymap ivy-pass-map
+            :action (lambda (entry)
+                      (let ((password (auth-source-pass-get 'secret entry)))
+                        (password-store-clear)
+                        (kill-new password)
+                        (setq password-store-kill-ring-pointer kill-ring-yank-pointer)
+                        (message "Copied %s to the kill ring. Will clear in %s seconds."
+                                 entry (password-store-timeout))
+                        (setq password-store-timeout-timer
+                              (run-at-time (password-store-timeout)
+                                           nil 'password-store-clear))))))
+
 (provide 'functions)
diff --git a/init/nixos.el b/init/nixos.el
index a75695d0c8e3..431ba705c3bc 100644
--- a/init/nixos.el
+++ b/init/nixos.el
@@ -65,7 +65,10 @@
 
       ;; Launch applications with completion (dmenu style!)
       (exwm-input-set-key (kbd "s-d") #'ivy-run-external-command)
-      (exwm-input-set-key (kbd "s-p") #'ivy-pass)
+      (exwm-input-set-key (kbd "s-p") #'ivy-password-store)
+      (exwm-input-set-key (kbd "C-s-p") '(lambda ()
+                                           (interactive)
+                                           (ivy-password-store "~/.aprila-secrets")))
 
       ;; Toggle between line-mode / char-mode
       (exwm-input-set-key (kbd "C-c C-t C-t") #'exwm-input-toggle-keyboard)