aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFredrik Salomonsson <plattfot@gmail.com>2020-05-04 11:33:46 -0700
committerFredrik Salomonsson <plattfot@gmail.com>2020-05-04 12:05:47 -0700
commit49a4253cf3cfb13dd5349eaa28fd8457389c43a5 (patch)
tree8b906eecb586589b79863f22aab26ee11d873482
parent2f5e77e8549feeca3c141398c0b9822a327c5fd5 (diff)
downloadpinentry-rofi-49a4253cf3cfb13dd5349eaa28fd8457389c43a5.tar.gz
Added support for MESSAGE and CONFIRM --one-button (#6)
More digging in the protocol, it can also use CONFIRM with one button aka MESSAGE, to show message to the user.
-rwxr-xr-xpinentry-rofi.scm25
1 files changed, 23 insertions, 2 deletions
diff --git a/pinentry-rofi.scm b/pinentry-rofi.scm
index 932950f..630377a 100755
--- a/pinentry-rofi.scm
+++ b/pinentry-rofi.scm
@@ -217,9 +217,13 @@ touch-file=/run/user/1000/gnupg/S.gpg-agent"
regex-match))
(define (pinentry-confirm pinentry line)
- (let ((getpin-re (make-regexp "^CONFIRM$"))
+ (let ((confirm-re (make-regexp "^CONFIRM$"))
+ (confirm-one-button-re
+ (make-regexp "^CONFIRM[[:blank:]]+--one-button[[:blank:]]*$"))
+ (message-re (make-regexp "^MESSAGE$"))
(regex-match #f))
- (when (set-and-return! regex-match (regexp-exec getpin-re line))
+ (cond
+ ((set-and-return! regex-match (regexp-exec confirm-re line))
;; Can probably do this with a pipe in both direction, but
;; manual warns about deadlocks so sticking with this for now.
(let* ((pipe (open-pipe
@@ -251,6 +255,23 @@ touch-file=/run/user/1000/gnupg/S.gpg-agent"
(format #t "ERR 277 Operation cancelled\n")
(force-output)
(set-pinentry-ok! pinentry #f)))))
+ ((or (set-and-return! regex-match (regexp-exec confirm-one-button-re line))
+ (set-and-return! regex-match (regexp-exec message-re line)))
+ (let ((pipe (open-pipe
+ (string-join
+ `("echo -e "
+ ,(format #f "'~a'" (pinentry-ok-button pinentry))
+ "|"
+ ,(format #f "env DISPLAY=~a" (pinentry-display pinentry))
+ "rofi -dmenu -disable-history -only-match -l 1 -i"
+ ,(format #f "-p '>'")
+ ,(format #f "-mesg ~s" (if (pinentry-error pinentry)
+ (format #f "~a\n~a"
+ (pinentry-error pinentry)
+ (pinentry-desc pinentry))
+ (pinentry-desc pinentry)))))
+ OPEN_READ)))
+ (close-pipe pipe))))
regex-match))
(define (pinentry-bye pinentry line)