diff --git a/init.el b/init.el index f3500d4..4b0d7c5 100644 --- a/init.el +++ b/init.el @@ -1917,6 +1917,32 @@ respectively." :init (setq epg-debug t epg-gpg-program "gpg")) +(use-package org-password-manager + :commands (org-password-manager-get-password-by-id) + :config (progn + + (defun org-password-manager-get-password-by-id (id) + "Retrieve password from Org item identified by ID. + +The password is assumed to be stored at the PASSWORD property." + + (let ((pom (org-id-find id 'marker))) + (unless (markerp pom) + (user-error "Cannot find item with id %s" id)) + + (let ((heading (org-entry-get pom "ITEM")) + (pw (org-entry-get pom "PASSWORD"))) + (when (null pw) + (user-error "PASSWORD property not set for ā€œ%sā€" heading)) + + (funcall interprogram-cut-function pw) + (run-at-time org-password-manager-default-password-wait-time + nil + (lambda () (funcall interprogram-cut-function ""))) + (message "Password for ā€œ%sā€ securly copied to system clipboard; will be overwritten in %s." + heading + org-password-manager-default-password-wait-time)))))) + ;; * Appearance