From 2cd189c8d8e7a8e32e5c745b201aeaac4c55dbf4 Mon Sep 17 00:00:00 2001 From: David Docampo Date: Wed, 15 Jan 2025 16:11:11 +0100 Subject: [PATCH 1/2] Focus confirmation window after prompt is shown --- ssh-askpass | 1 + 1 file changed, 1 insertion(+) diff --git a/ssh-askpass b/ssh-askpass index 4a8508a..75efc91 100755 --- a/ssh-askpass +++ b/ssh-askpass @@ -26,6 +26,7 @@ fi # create dialog window result=$(osascript \ -e 'tell application "Terminal"' \ + -e 'activate' \ -e "display dialog \"$*\" buttons {\"Deny\", \"Allow for 1min\", \"Allow\"} default button 3 with title \"SSH Agent\" with icon caution" \ -e 'end tell') From 4dbae92d74208de6b14c542fdd00e0e6520046d5 Mon Sep 17 00:00:00 2001 From: David Docampo Date: Thu, 16 Jan 2025 14:03:09 +0100 Subject: [PATCH 2/2] Always open dialog in current application and play notification sound --- ssh-askpass | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ssh-askpass b/ssh-askpass index 75efc91..7385986 100755 --- a/ssh-askpass +++ b/ssh-askpass @@ -9,6 +9,8 @@ set -o nounset # exit if one command in a pipeline fails set -o pipefail +SOUND="/System/Library/Sounds/Tink.aiff" + # check if paused for 1 minute if [ -e '/tmp/disable-askpass' ] then @@ -23,10 +25,14 @@ then fi -# create dialog window +# create dialog window and play sound +sleep 0.1 && afplay "$SOUND" & \ result=$(osascript \ - -e 'tell application "Terminal"' \ - -e 'activate' \ + -e "tell application \"System Events\"" \ + -e "set frontmostProcess to first process where it is frontmost" \ + -e "set appName to name of frontmostProcess" \ + -e "end tell" \ + -e "tell application appName" \ -e "display dialog \"$*\" buttons {\"Deny\", \"Allow for 1min\", \"Allow\"} default button 3 with title \"SSH Agent\" with icon caution" \ -e 'end tell')