From 23c57ff24840c6f612ffd19effbac70a2c218865 Mon Sep 17 00:00:00 2001 From: Yves Fischer Date: Fri, 15 Jan 2016 19:27:34 +0100 Subject: cern-scripts: package --- .../src/main/resources/bin/dmenu-pass.sh | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 packages/cern-scripts/src/main/resources/bin/dmenu-pass.sh (limited to 'packages/cern-scripts/src/main/resources/bin/dmenu-pass.sh') diff --git a/packages/cern-scripts/src/main/resources/bin/dmenu-pass.sh b/packages/cern-scripts/src/main/resources/bin/dmenu-pass.sh new file mode 100755 index 0000000..bb3be7a --- /dev/null +++ b/packages/cern-scripts/src/main/resources/bin/dmenu-pass.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +shopt -s nullglob globstar + +prefix=${PASSWORD_STORE_DIR-~/.password-store} +password_files=( "$prefix"/**/*.gpg ) +password_files=( "${password_files[@]#"$prefix"/}" ) +password_files=( "${password_files[@]%.gpg}" ) + +password=$(printf '%s\n' "${password_files[@]}" | dmenu "$@") + +[[ -n $password ]] || exit + +while true; do + pass show "$password" 2>&1 \ + | sed -e 's/^pass:.*/pass: XXXX/' \ + | xmessage -file - \ + -buttons "Done:1,Copy 'login':2,Copy 'pass':3,Copy all:4" \ + -default "Done" \ + -nearmouse -timeout 10 + case "$?" in + 2) + pass show "$password" 2>&1 \ + | sed -ne 's/^login: \(.*\)/\1/p' \ + | xclip -i -verbose -l 1 2>/dev/null + ;; + 3) + pass show "$password" 2>&1 \ + | sed -ne 's/^pass: \(.*\)/\1/p' \ + | xclip -i -verbose -l 1 2>/dev/null + ;; + 4) + pass show "$password" 2>&1 \ + | xclip -i -verbose -l 1 2>/dev/null + ;; + *) + break + ;; + esac +done -- cgit v1.2.1