mybin

my ~/bin
git clone https://a3nm.net/git/mybin/
Log | Files | Refs | README

commit da4a3385422ea2fc67cfdfb43d568cccc3e3a181
parent 87fb5ea3b4151ff79e8dbfb8904a11def6032b7e
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Fri, 16 Oct 2015 22:47:18 +0100

xpass

Diffstat:
xpass | 43+++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+), 0 deletions(-)

diff --git a/xpass b/xpass @@ -0,0 +1,43 @@ +#!/bin/bash + +# type passwords with xdotool, messages with zenity +# usage: choose an entry in the dmenu to type the password for it +# type "FILE USER" to generate a new password for FILE and type it +# additionally storing "USER" as second line in the file + +# inspired by similar scripts, e.g.: +# https://gist.github.com/ivyl/7429582 +# http://www.christoph-egger.org/weblog/entry/48 + +# we need to prompt with gtk +# this may work by default, otherwise, see the my-pinentry wrapper command +# fortunately, pass uses gpg2 + +set -x + +export PINENTRY_USER_DATA="gtk" + +cd ~/.password-store + +# my-rofi is a dmenu wrapper + +RET=$(ls *.gpg | sed 's/\.gpg$//' | ~/bin/my-rofi) +FILE=$(echo "$RET" | awk '{print $1}') +USER=$(echo "$RET" | awk '{print $2}') +if [ ! -f "${FILE}.gpg" ] +then + # file does not exist, create password + # save anything specified on the commandline to the file + echo "generate" + echo -e "will be replaced by password\n$USER" | pass add -m "$FILE" || \ + (zenity --error --text 'problem with pass add; aborting'; exit 2) + PINENTRY_USER_DATA="gtk" pass generate -i -n "$FILE" 12 || \ + (zenity --error --text 'problem with pass generate; aborting'; exit 2) +fi + +# file now exists, retrieve password +PASSWORD=$(pass "$FILE" | head -1) +WINDOW=$(xdotool getactivewindow) + +echo "type --window $WINDOW $PASSWORD" | xdotool - +