Hi all,
After using pass and passmenu for some time, my problem is that if the gpg
pinentry window pops up sometimes other programs can steal focus upon the
closing of that window. This pull request adds the following:
1. An option to reactivate the currently active window with the -a or
--activate option
2. A -t shortcut for the --type option and also the handling of -at or
-ta
3. A check for the existence of xdotool
4. Return codes for failure:
1. Cancelled selection (1)
2. xdotool not found in path and it is required by a option (2)
As I'm using gmail I couldn't find a way to insert the patch without
loosing the spaces, so I attached it. Hope it is okay and this can help to
someone else too.
-----BEGIN PGP SIGNATURE-----
iQIzBAABCgAdFiEEEa3x2MSMZ6TOzrbsbfPTaG2Lx3gFAlzqIOMACgkQbfPTaG2L
x3gfmA//aZBfTuI8v2Wghk7kFuBTTW3mp/GtFMUUtV5Ew8ZRAoBcMcFFI/OrSSR1
C0wS6en4yf4BXtXvoe9HIDdMI7FRCfLPZ1v+hTSpbH3ZSXVRgvpj5P+vfGN5GYlc
rGwRUdSqtkWByfoUk0CFEZoWMazMewg9wT7nY6hAECfhwb0S8ueA9ekizgO+C/6g
keQVd7VnqzvkVz2ApDss2OjJHNtItO1i/LFXaDLTnBMAzLXEVoJ3dTrDROV3naFN
UWYWJAje0HbZevPZVi3jWLTTxVYLzifJ0X/UYwpKMO8Dem4fcy+EtSWxva4iXX9c
bCm6fpHLY0/DrqNjWb481OK4rp3qtnj4xP734AJiGA8Wt8qI0gVTk0rtU5dGU+OG
RRS3ILy9ObyfJ21rkY8MdiIZevxek50ju8da3CMJe44T0i0LddRaA5zHV0YIfZAd
nlA8AsPLztPWp9LmDGU1ata3Ag4DuRrsqitPsNLDmcV9XmEX6omyQtL/B2HLh/Bg
tqWETNY78Ld5wPQhzuDK9XhdNs/CBItqNDn9nQF1ydRoCUPnd3JwTHzuk7JZRkq2
x3u9U2/sjGyz61uu/31dwKqQeZiYpSPzLOSg595kcLBoB1ZzmlKX13/hur3A0gUv
M7ivmvF6L7upzADUXjIu9hjCHWaq397ivKeYnS0uQaZkVsT0wro=
=Gxdp
-----END PGP SIGNATURE-----
From ff7757bc65259bee1366dab27dce6fd49b62f9f4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bal=C3=A1zs=20V=C3=A1radi?= <[email protected]>
Date: Sun, 26 May 2019 07:10:50 +0200
Subject: [PATCH] Add activate option to passmenu
---
contrib/dmenu/README.md | 6 +++--
contrib/dmenu/passmenu | 54 +++++++++++++++++++++++++++++++++++------
2 files changed, 51 insertions(+), 9 deletions(-)
diff --git a/contrib/dmenu/README.md b/contrib/dmenu/README.md
index 9d54fb4..52baca3 100644
--- a/contrib/dmenu/README.md
+++ b/contrib/dmenu/README.md
@@ -1,12 +1,14 @@
`passmenu` is a [dmenu][]-based interface to [pass][], the standard Unix
password manager. This design allows you to quickly copy a password to the
clipboard without having to open up a terminal window if you don't already have
-one open. If `--type` is specified, the password is typed using [xdotool][]
+one open. If `-a` or `--activate` is specified the currently active window will
+be made active again after copying/before typing the password using [xdotool][].
+If `-t` or `--type` is specified, the password is typed using [xdotool][]
instead of copied to the clipboard.
# Usage
- passmenu [--type] [dmenu arguments...]
+ passmenu [-a|--activate] [-t|--type] [dmenu arguments...]
[dmenu]: http://tools.suckless.org/dmenu/
[xdotool]: http://www.semicomplete.com/projects/xdotool/
diff --git a/contrib/dmenu/passmenu b/contrib/dmenu/passmenu
index 83268bc..3bbabb5 100755
--- a/contrib/dmenu/passmenu
+++ b/contrib/dmenu/passmenu
@@ -2,11 +2,46 @@
shopt -s nullglob globstar
+type -P xdotool > /dev/null
+xdotool_available=$?
+
typeit=0
-if [[ $1 == "--type" ]]; then
+set_typeit(){
+ if [[ $xdotool_available -ne 0 ]]; then
+ echo For typed password support please install xdotool.
+ exit 2
+ fi
typeit=1
- shift
-fi
+}
+
+set_active_window(){
+ if [[ $xdotool_available -ne 0 ]]; then
+ echo For window activation support please install xdotool.
+ exit 2
+ fi
+ active_window=$(xdotool getactivewindow)
+}
+
+while [[ $# -gt 0 ]]; do
+ case $1 in
+ -t|--type)
+ set_typeit
+ shift
+ ;;
+ -a|--activate)
+ set_active_window
+ shift
+ ;;
+ -at|-ta)
+ set_active_window
+ set_typeit
+ shift
+ ;;
+ *)
+ break
+ esac
+done
+
prefix=${PASSWORD_STORE_DIR-~/.password-store}
password_files=( "$prefix"/**/*.gpg )
@@ -15,11 +50,16 @@ password_files=( "${password_files[@]%.gpg}" )
password=$(printf '%s\n' "${password_files[@]}" | dmenu "$@")
-[[ -n $password ]] || exit
+[[ -n $password ]] || exit 1
if [[ $typeit -eq 0 ]]; then
pass show -c "$password" 2>/dev/null
+
+ if [[ ! -z "${active_window}" ]]; then
+ xdotool windowactivate $active_window
+ fi
else
- pass show "$password" | { IFS= read -r pass; printf %s "$pass"; } |
- xdotool type --clearmodifiers --file -
-fi
+ pass show "$password" | { IFS= read -r pass;
+ [[ ! -z "${active_window}" ]] && xdotool windowactivate $active_window;
+ printf %s "$pass"; } | xdotool type --clearmodifiers --file -
+fi
\ No newline at end of file
--
2.17.1
_______________________________________________
Password-Store mailing list
[email protected]
https://lists.zx2c4.com/mailman/listinfo/password-store