diff options
author | Fredrik Salomonsson <plattfot@gmail.com> | 2020-05-04 12:21:43 -0700 |
---|---|---|
committer | Fredrik Salomonsson <plattfot@gmail.com> | 2020-05-04 12:21:52 -0700 |
commit | 83e0ca672dc63833d3371cd347c6ae98b1911a9f (patch) | |
tree | 54a48115dd8b915fc64025b5099c8f3e4e1d0398 /pinentry-rofi.scm | |
parent | 83c2842004a590ac1adae5c005b0ddf365f146fb (diff) | |
parent | a3aa5255a2c4a873fc6368138c138f08ff06fbb9 (diff) | |
download | pinentry-rofi-83e0ca672dc63833d3371cd347c6ae98b1911a9f.tar.gz |
Merge branch 'better_default_7' (#7)
Diffstat (limited to 'pinentry-rofi.scm')
-rwxr-xr-x | pinentry-rofi.scm | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/pinentry-rofi.scm b/pinentry-rofi.scm index 96bdd91..0c4a355 100755 --- a/pinentry-rofi.scm +++ b/pinentry-rofi.scm @@ -38,7 +38,7 @@ (exit #f)) (define-record-type <pinentry> - (make-pinentry ok prompt desc visibility display logfile) + (make-pinentry ok prompt ok-button cancel-button display logfile) pinentry? (ok pinentry-ok set-pinentry-ok!) (prompt pinentry-prompt set-pinentry-prompt!) @@ -140,8 +140,32 @@ default-cf-visi=Do you really want to make your passphrase visible on the screen default-tt-visi=Make passphrase visible default-tt-hide=Hide passphrase touch-file=/run/user/1000/gnupg/S.gpg-agent" - (let ((option-re (make-regexp "^OPTION (.+)$"))) - (regexp-exec option-re line))) + (let ((regex-match #f) + (option-re (make-regexp "^OPTION (.+)$"))) + (cond + ((set-and-return! regex-match + (regexp-exec + (make-regexp "^OPTION[[:blank:]]+default-ok=(.+)$") line)) + (pinentry-set-button + set-pinentry-ok-button! + pinentry + (match:substring regex-match 1))) + ((set-and-return! regex-match + (regexp-exec + (make-regexp "^OPTION[[:blank:]]+default-cancel=(.+)$") line)) + (pinentry-set-button + set-pinentry-cancel-button! + pinentry + (match:substring regex-match 1))) + ((set-and-return! regex-match + (regexp-exec + (make-regexp "^OPTION[[:blank:]]+default-prompt=(.+)$") line)) + (pinentry-set-mesg + set-pinentry-prompt! + pinentry + (match:substring regex-match 1))) + ((set-and-return! regex-match (regexp-exec option-re line)))) + regex-match)) (define (pinentry-getinfo pinentry line) "Process line if it starts with GETINFO" @@ -274,11 +298,9 @@ touch-file=/run/user/1000/gnupg/S.gpg-agent" (string-join `("echo -e " ,(format #f "'~a\n~a'" - ;; Find a cleaner way, e.g. or - (or (pinentry-ok-button pinentry) "ok") + (pinentry-ok-button pinentry) (or (pinentry-notok-button pinentry) - (pinentry-cancel-button pinentry) - "cancel")) + (pinentry-cancel-button pinentry))) "|" ,(format #f "env DISPLAY=~a" (pinentry-display pinentry)) "rofi -dmenu -disable-history -only-match -l 2 -i" @@ -292,8 +314,7 @@ touch-file=/run/user/1000/gnupg/S.gpg-agent" (pass (get-string-all pipe)) (status (close-pipe pipe))) (if (and (equal? (status:exit-val status) 0) - (string=? (string-trim-right pass) - (or (pinentry-ok-button pinentry) "ok"))) + (string=? (string-trim-right pass) (pinentry-ok-button pinentry))) (set-pinentry-ok! pinentry #t) (begin (format #t "ERR 277 Operation cancelled\n") @@ -347,7 +368,7 @@ touch-file=/run/user/1000/gnupg/S.gpg-agent" (help (single-char #\h) (value #f)))) (default-display ":0") (options (getopt-long (command-line) option-spec)) - (pinentry (make-pinentry #t "Passphrase:" "" #f + (pinentry (make-pinentry #t "Passphrase:" "Ok" "Cancel" (option-ref options 'display default-display) (let ((logfile (option-ref options 'log #f))) (when logfile |