[gopass] Add password revealing to rofi-gopass

When an individual entry is opened the hidden password can now be
revealed, using `Alt+s` by default.
This commit is contained in:
Marty Oehme 2020-06-17 11:40:30 +02:00
parent 589211ed3a
commit 7456bb14ab
No known key found for this signature in database
GPG key ID: 0CCB0526EFB9611A
3 changed files with 29 additions and 15 deletions

View file

@ -3,7 +3,7 @@ root:
autoclip: true autoclip: true
autoprint: false autoprint: false
autoimport: true autoimport: true
autosync: true autosync: false
check_recipient_hash: false check_recipient_hash: false
cliptimeout: 45 cliptimeout: 45
concurrency: 1 concurrency: 1

View file

@ -61,6 +61,7 @@ set_defaults() {
KEY_CLIP_PASS="${RGP_KEY_CLIP_PASS:-$(get_config KEY_CLIP_PASS Ctrl+Alt+p)}" KEY_CLIP_PASS="${RGP_KEY_CLIP_PASS:-$(get_config KEY_CLIP_PASS Ctrl+Alt+p)}"
KEY_ENTRYMENU_FILL="${RGP_KEY_ENTRYMENU_FILL:-$(get_config KEY_ENTRYMENU_FILL Return)}" KEY_ENTRYMENU_FILL="${RGP_KEY_ENTRYMENU_FILL:-$(get_config KEY_ENTRYMENU_FILL Return)}"
KEY_ENTRYMENU_CLIP="${RGP_KEY_ENTRYMENU_CLIP:-$(get_config KEY_ENTRYMENU_CLIP Alt+Return)}" KEY_ENTRYMENU_CLIP="${RGP_KEY_ENTRYMENU_CLIP:-$(get_config KEY_ENTRYMENU_CLIP Alt+Return)}"
KEY_ENTRYMENU_SHOWFIELD="${KEY_ENTRYMENU_SHOWFIELD:-$(get_config KEY_ENTRYMENU_SHOWFIELD Alt+s)}"
KEY_ENTRYMENU_QUIT="${RGP_KEY_ENTRYMENU_QUIT:-$(get_config KEY_ENTRYMENU_QUIT Alt+BackSpace)}" KEY_ENTRYMENU_QUIT="${RGP_KEY_ENTRYMENU_QUIT:-$(get_config KEY_ENTRYMENU_QUIT Alt+BackSpace)}"
AUTOFILL_BACKEND="${RGP_BACKEND:-$(get_config AUTOFILL_BACKEND xdotool)}" AUTOFILL_BACKEND="${RGP_BACKEND:-$(get_config AUTOFILL_BACKEND xdotool)}"
@ -162,21 +163,29 @@ autofill() {
# opens a menu for the specified gopass entry, containing its individual fields # opens a menu for the specified gopass entry, containing its individual fields
entrymenu() { entrymenu() {
local entry="$1" local entry="$1"
local deobfuscate="$2"
local k_entrymenu_fill="${KEY_ENTRYMENU_FILL}" local k_entrymenu_fill="${KEY_ENTRYMENU_FILL}"
local k_entrymenu_clip="${KEY_ENTRYMENU_CLIP}" local k_entrymenu_clip="${KEY_ENTRYMENU_CLIP}"
local k_entrymenu_showfield="${KEY_ENTRYMENU_SHOWFIELD}"
local k_entrymenu_quit="${KEY_ENTRYMENU_QUIT}" local k_entrymenu_quit="${KEY_ENTRYMENU_QUIT}"
local pass_obfuscation="(hidden)" local pass
if [ "$deobfuscate" = "true" ]; then
pass="$(show_password "$entry")"
else
pass="(hidden)"
fi
local field local field
field=$( field=$(
printf "password: %s\n%s" "$pass_obfuscation" "$(list_fields "$entry")" | printf "password: %s\n%s" "$pass" "$(list_fields "$entry")" |
_rofi \ _rofi \
-kb-accept-entry "" \ -kb-accept-entry "" \
-kb-custom-1 "$k_entrymenu_fill" \ -kb-custom-1 "$k_entrymenu_fill" \
-kb-custom-2 "$k_entrymenu_clip" \ -kb-custom-2 "$k_entrymenu_clip" \
-kb-custom-3 "$k_entrymenu_quit" \ -kb-custom-3 "$k_entrymenu_quit" \
-mesg " ᐊ $k_entrymenu_quit ᐊ | $k_entrymenu_fill: fill selection | $k_entrymenu_clip: clip selection |" -kb-custom-4 "$k_entrymenu_showfield" \
-mesg " ᐊ $k_entrymenu_quit ᐊ | $k_entrymenu_fill: fill selection | $k_entrymenu_clip: clip selection | $k_entrymenu_showfield: reveal password"
) )
exit_value=$? exit_value=$?
exit_check "$exit_value" exit_check "$exit_value"
@ -203,6 +212,9 @@ entrymenu() {
"12") "12")
main main
;; ;;
"13")
entrymenu "$entry" "true"
;;
esac esac
} }

View file

@ -22,8 +22,10 @@ There are several keybindings available, to either fill or copy to clipboard the
| Alt+p | Auto-fill password | KEY_FILL_PASS | | Alt+p | Auto-fill password | KEY_FILL_PASS |
| Ctrl+Alt+u | Send username to clipboard | KEY_CLIP_USER | | Ctrl+Alt+u | Send username to clipboard | KEY_CLIP_USER |
| Ctrl+Alt+p | Send password to clipboard | KEY_CLIP_PASS | | Ctrl+Alt+p | Send password to clipboard | KEY_CLIP_PASS |
| Return | Auto-fill selected field (from opened entry) | KEY_ENTRYMENU_FILL | | From opened entry: | | |
| Alt+Return | Send selected field to clipboard (from opened entry) | KEY_ENTRYMENU_CLIP | | Return | Auto-fill selected field | KEY_ENTRYMENU_FILL |
| Alt+Return | Send selected field to clipboard | KEY_ENTRYMENU_CLIP |
| Alt+s | Reveal contents of the password field | KEY_ENTRYMENU_SHOWFIELD |
| Alt+BackSpace | Close individual entry, return to overview | KEY_ENTRYMENU_QUIT | | Alt+BackSpace | Close individual entry, return to overview | KEY_ENTRYMENU_QUIT |
These keys, as well as the additional configuration can be changed by setting the corresponding environment variable, through a configuration file, or at the top of the script file itself. The script tries to follow xdg-specification, meaning it looks for a configuration file in the following directories (in descending order): These keys, as well as the additional configuration can be changed by setting the corresponding environment variable, through a configuration file, or at the top of the script file itself. The script tries to follow xdg-specification, meaning it looks for a configuration file in the following directories (in descending order):