aboutsummaryrefslogtreecommitdiffstats
path: root/rofi-pinentry.scm
diff options
context:
space:
mode:
authorFredrik Salomonsson <plattfot@gmail.com>2018-11-06 23:27:35 -0800
committerFredrik Salomonsson <plattfot@gmail.com>2018-11-06 23:27:35 -0800
commit67f9e9fd768586b251f7ac3113b9729cd6074f6f (patch)
tree0051082804cb54a0559c9740de3c9c225c206bc7 /rofi-pinentry.scm
parenteed9d47b53101fc611b8a8454faa3454f08a28fd (diff)
downloadpinentry-rofi-67f9e9fd768586b251f7ac3113b9729cd6074f6f.tar.gz
Fixed mesg, added envvars and error if abort the pinentry
Still having issues with newlines gets printed verbatim.
Diffstat (limited to 'rofi-pinentry.scm')
-rwxr-xr-xrofi-pinentry.scm28
1 files changed, 20 insertions, 8 deletions
diff --git a/rofi-pinentry.scm b/rofi-pinentry.scm
index e74be85..c484f9a 100755
--- a/rofi-pinentry.scm
+++ b/rofi-pinentry.scm
@@ -90,7 +90,14 @@ touch-file=/run/user/1000/gnupg/S.gpg-agent"
(let ((setdesc-re (make-regexp "^SETDESC (.+)$"))
(regex-match #f))
(when (set-and-return! regex-match (regexp-exec setdesc-re line))
- (set-pinentry-desc! pinentry (match:substring regex-match 1)))
+ (let* ((mesg (match:substring regex-match 1))
+ (mesg (regexp-substitute/global #f "<" mesg 'pre "&lt;" 'post))
+ (mesg (regexp-substitute/global
+ #f "%([[:xdigit:]]{2})" mesg 'pre
+ (lambda (m) (integer->char
+ (string->number
+ (match:substring m 1) 16))) 'post)))
+ (set-pinentry-desc! pinentry mesg)))
regex-match))
(define (pinentry-setprompt pinentry line)
@@ -102,19 +109,24 @@ touch-file=/run/user/1000/gnupg/S.gpg-agent"
regex-match))
(define (pinentry-getpin pinentry line)
- (let ((rofi "rofi -dmenu -input /dev/null -disable-history -lines 1 ~a -p ~s ~a ~s")
+ (let ((rofi "env ~a rofi -dmenu ~a -disable-history -lines 1 ~a -p ~s ~a ~s")
(getpin-re (make-regexp "^GETPIN$"))
(regex-match #f))
(when (set-and-return! regex-match (regexp-exec getpin-re line))
- (let* ((rofi-cmd (format #f rofi
- (if (pinentry-visibility pinentry) "" "-password")
- (pinentry-prompt pinentry)
- (if (string-empty? (pinentry-desc pinentry)) "" "-mesg")
- (pinentry-desc pinentry)))
+ (let* ((pipe (open-input-pipe "systemctl --user show-environment"))
+ (env (get-string-all pipe))
+ (status (close-pipe pipe))
+ (rofi-cmd (format #f rofi
+ (regexp-substitute/global #f "[\n]" env 'pre " " 'post)
+ "-input /dev/null"
+ (if (pinentry-visibility pinentry) "" "-password")
+ (pinentry-prompt pinentry)
+ (if (string-empty? (pinentry-desc pinentry)) "" "-mesg")
+ (pinentry-desc pinentry)))
(pipe (open-input-pipe rofi-cmd))
(pass (get-string-all pipe))
(status (close-pipe pipe)))
- (if status
+ (if (equal? (status:exit-val status) 0)
(unless (string-empty? pass)
(format #t "D ~a" pass)
(force-output))