aboutsummaryrefslogtreecommitdiffstats
path: root/pinentry-wsl-ps1.sh
diff options
context:
space:
mode:
authorDale Phurrough <dale@hidale.com>2018-03-05 18:27:24 +0100
committerDale Phurrough <dale@hidale.com>2018-03-05 18:27:24 +0100
commitbeb56d7a51eab19847d148bab49837e9eb49075a (patch)
tree6b54fb01480f4b98c1dc3b894039013fe792a11b /pinentry-wsl-ps1.sh
parent3f196ac3e924797137f10a0413ae20e5c0ccee03 (diff)
downloadpinentry-rofi-v0.2.0.tar.gz
add toast notify, optional logs; update READMEv0.2.0
- added toast notifications when password retrieved from Win Credential Store; can optionally disable them - added optional debug log - added README setup details and troubleshooting steps
Diffstat (limited to 'pinentry-wsl-ps1.sh')
-rw-r--r--pinentry-wsl-ps1.sh31
1 files changed, 30 insertions, 1 deletions
diff --git a/pinentry-wsl-ps1.sh b/pinentry-wsl-ps1.sh
index 0a7ab00..ceecb29 100644
--- a/pinentry-wsl-ps1.sh
+++ b/pinentry-wsl-ps1.sh
@@ -25,9 +25,11 @@
# Note security perspectives like https://security.stackexchange.com/questions/119765/how-secure-is-the-windows-credential-manager
# Possible values for PERSISTENCE are: "", "Session", "LocalMachine", or "Enterprise"
PERSISTENCE=""
+NOTIFY="1"
+DEBUGLOG=""
# Do not casually edit the below values
-VERSION="0.1.0"
+VERSION="0.2.0"
TIMEOUT="0"
DESCRIPTION="Enter password for GPG key"
PROMPT="Password:"
@@ -43,6 +45,7 @@ EXTPASSCACHE="0"
REPEATPASSWORD="0"
REPEATDESCRIPTION="Confirm password for GPG key"
REPEATERROR="Error: Passwords did not match."
+GRABKEYBOARD="0"
# convert Assuan protocol error into an ERR number, e.g. echo -n $(( (5 << 24) | $1 ))
assuan_result() {
@@ -119,6 +122,18 @@ DLM
out-null
DLM
)
+ # idea from http://thewindowscollege.com/display-toast-notifications-windows-10.html
+ # alt1: https://gist.github.com/loge5/7ec41e2e2f0e0293fdcc5155499e9072
+ # alt2: https://gist.github.com/Windos/9aa6a684ac583e0d38a8fa68196bc2dc
+ local cmd_toast=$(cat <<-DLM
+ [reflection.assembly]::loadwithpartialname("System.Windows.Forms")
+ [reflection.assembly]::loadwithpartialname("System.Drawing")
+ \$notify = new-object system.windows.forms.notifyicon
+ \$notify.icon = [System.Drawing.SystemIcons]::Information
+ \$notify.visible = \$true
+ \$notify.showballoontip(10, "GPG pinentry-wsl-ps1", "GPG password retrieved from Windows Credential Manager", [system.windows.forms.tooltipicon]::Info)
+DLM
+ )
local credpassword
local credpasswordrepeat
local passwordfromcache=0
@@ -129,6 +144,9 @@ DLM
credpassword="$(powershell.exe -nologo -noprofile -noninteractive -command "$cmd_lookup")"
if [ -n "$credpassword" ]; then
echo -e "S PASSWORD_FROM_CACHE\nD $credpassword\nOK"
+ if [ "$NOTIFY" == "1" ]; then
+ powershell.exe -nologo -noprofile -noninteractive -command "$cmd_toast" > /dev/null
+ fi
return
fi
fi
@@ -350,6 +368,14 @@ setoption() {
default-prompt)
setprompt "$value"
;;
+ grab)
+ GRABKEYBOARD="1"
+ echo "OK"
+ ;;
+ no-grab)
+ GRABKEYBOARD="0"
+ echo "OK"
+ ;;
*)
echo "OK"
;;
@@ -365,6 +391,9 @@ fi
# main loop to read stdin and respond
echo "OK Your orders please"
while IFS= read -r line; do
+ if [ -n "$DEBUGLOG" ]; then
+ echo "$line" >> "$DEBUGLOG"
+ fi
action="$(echo $line | cut -d' ' -f1)"
args="$(echo $line | cut -d' ' -s -f2-)"
case $action in