aboutsummaryrefslogtreecommitdiffstats
path: root/pinentry-rofi.scm
diff options
context:
space:
mode:
authorFredrik Salomonsson <plattfot@gmail.com>2019-06-06 19:47:38 -0700
committerFredrik Salomonsson <plattfot@gmail.com>2019-06-06 19:47:38 -0700
commit1a13b7518b3e450ccd219ee654f7a5862cef996f (patch)
tree3a8b75f0aa4e965ce66d6e2c894eaf5bd931a34d /pinentry-rofi.scm
parentb513d5f2c8d9f0eea044a455352eac09e1e05b8a (diff)
downloadpinentry-rofi-1a13b7518b3e450ccd219ee654f7a5862cef996f.tar.gz
Wrapped script in a main procedure
To be able to run it from the REPL
Diffstat (limited to 'pinentry-rofi.scm')
-rwxr-xr-xpinentry-rofi.scm54
1 files changed, 28 insertions, 26 deletions
diff --git a/pinentry-rofi.scm b/pinentry-rofi.scm
index c8173f0..b19eede 100755
--- a/pinentry-rofi.scm
+++ b/pinentry-rofi.scm
@@ -1,4 +1,5 @@
-#! /usr/bin/guile -s
+#! /usr/bin/guile \
+-e main -s
!#
;; Copyright © 2016 Quentin "Sardem FF7" Glidic
@@ -30,7 +31,7 @@
(ice-9 regex)
(ice-9 getopt-long))
-(define pinentry-rofi-guile-version "0.3.0")
+(define pinentry-rofi-guile-version "0.4.0")
(when (equal? (system-file-name-convention) 'windows)
(format #t "Only support posix systems!")
@@ -131,12 +132,12 @@ touch-file=/run/user/1000/gnupg/S.gpg-agent"
"env"
(format #f "DISPLAY=~a" (pinentry-display pinentry))
"rofi"
- "-dmenu"
- "-input" "/dev/null"
+ "-dmenu"
+ "-input" "/dev/null"
"-disable-history"
- "-lines" "1"
+ "-lines" "1"
(if (pinentry-visibility pinentry) "" "-password")
- "-p" (pinentry-prompt pinentry)
+ "-p" (pinentry-prompt pinentry)
"-mesg" (pinentry-desc pinentry)))
(pass (get-string-all pipe))
(status (close-pipe pipe)))
@@ -177,17 +178,18 @@ touch-file=/run/user/1000/gnupg/S.gpg-agent"
(force-output))
(pinentry-loop pinentry input-port))))
-(let* ((option-spec
- '((display (single-char #\d) (value #t))
- (xauthority (single-char #\a) (value #t))
- (version (single-char #\v) (value #f))
- (help (single-char #\h) (value #f))))
- (default-display ":0")
- (options (getopt-long (command-line) option-spec))
- (pinentry (make-pinentry #t "Passphrase:" "" #f
- (option-ref options 'display default-display))))
- (when (option-ref options 'help #f)
- (format #t "\
+(define (main args)
+ (let* ((option-spec
+ '((display (single-char #\d) (value #t))
+ (xauthority (single-char #\a) (value #t))
+ (version (single-char #\v) (value #f))
+ (help (single-char #\h) (value #f))))
+ (default-display ":0")
+ (options (getopt-long (command-line) option-spec))
+ (pinentry (make-pinentry #t "Passphrase:" "" #f
+ (option-ref options 'display default-display))))
+ (when (option-ref options 'help #f)
+ (format #t "\
Usage: ~a [OPTIONS]
Options:
-d, --display DISPLAY Set display, default is ~s.
@@ -196,12 +198,12 @@ Options:
Author:
Fredrik \"PlaTFooT\" Salomonsson
"
-(car (command-line))
-default-display)
- (exit #t))
- (when (option-ref options 'version #f)
- (format #t "pinentry-rofi-guile version ~a\n" pinentry-rofi-guile-version)
- (exit #t))
- (format #t "OK Please go ahead\n")
- (force-output)
- (pinentry-loop pinentry (current-input-port)))
+ (car (command-line))
+ default-display)
+ (exit #t))
+ (when (option-ref options 'version #f)
+ (format #t "pinentry-rofi-guile version ~a\n" pinentry-rofi-guile-version)
+ (exit #t))
+ (format #t "OK Please go ahead\n")
+ (force-output)
+ (pinentry-loop pinentry (current-input-port))))