[pass] [PATCH 3/3] passmenu: Add option to notify-send after copying to clipboard

Emil Lundberg lundberg.emil at gmail.com
Sat Jul 25 18:21:37 CEST 2015


---
 contrib/dmenu/passmenu | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/contrib/dmenu/passmenu b/contrib/dmenu/passmenu
index 34653a8..9cd3e52 100755
--- a/contrib/dmenu/passmenu
+++ b/contrib/dmenu/passmenu
@@ -5,11 +5,13 @@ shopt -s nullglob globstar
 PROGRAM="${0##*/}"
 
 typeit=0
+notify=0
 
-opts="$(getopt -o "" -l typeit -n "$PROGRAM" -- "$@")"
-[[ $? -ne 0 ]] && (echo "Usage: $PROGRAM [--typeit]" >&2 ; exit 1)
+opts="$(getopt -o "" -l notify,typeit -n "$PROGRAM" -- "$@")"
+[[ $? -ne 0 ]] && (echo "Usage: $PROGRAM [--notify] [--typeit]" >&2 ; exit 1)
 eval set -- "$opts"
 while true; do case $1 in
+	--notify) notify=1; shift ;;
 	--typeit) typeit=1; shift ;;
 	--) shift; break ;;
 esac done
@@ -24,6 +26,12 @@ password=$(printf '%s\n' "${password_files[@]}" | dmenu "$@")
 [[ -n $password ]] || exit
 
 if [[ $typeit -eq 0 ]]; then
+	if [[ $notify -ne 0 ]] && hash notify-send; then
+		PASSWORD_STORE_POST_COPY_HOOK() {
+			notify-send -a "${PROGRAM}" -u normal -t 2000 "Copied $1" "$2"
+		}
+		export -f PASSWORD_STORE_POST_COPY_HOOK
+	fi
 	pass show -c "$password" 2>/dev/null
 else
 	pass show "$password" |
-- 
2.4.6



More information about the Password-Store mailing list