mybin

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

commit 004e5010ab9af8874381b767ce68ef5a4263af3b
parent eead112795a265d4e081e70888a7113ebf57a7c5
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Mon, 18 Jul 2016 11:53:37 +0200

support to show result, show login, etc.

Diffstat:
xpass | 53++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 52 insertions(+), 1 deletion(-)

diff --git a/xpass b/xpass @@ -46,7 +46,58 @@ fi # file now exists, retrieve password PASSWORD=$(pass "$FILE" | head -1) +if [[ $USER = "login" || $USER = "user" || $USER = "fill" ]] +then + # user wanted login instead of password + USERDAT=$(pass "$FILE" | grep 'login:' | head -1 | grep '^login:' | cut -d ':' -f2 | cut -c 2-) + if [ -z $USERDAT ] + then + # try another way + # keep line containing '@' + USERDAT=$(pass "$FILE" | grep '@' | head -1 | sed 's/\(.* \)\?\([^ ]*@[^ ]*\)\( .*\)\?/\2/g') + if [ -z $USERDAT ] + then + # fallback to default + USERDAT=$(whoami) + fi + fi +fi WINDOW=$(xdotool getactivewindow) -echo "type --window $WINDOW $PASSWORD" | xdotool - +function dologin() { + echo "type --window $WINDOW $USERDAT" | xdotool - +} + +function dofill() { + echo "type --window $WINDOW $USERDAT" | xdotool - + sleep 0.1 + echo "key --window $WINDOW Tab" | xdotool - + sleep 0.1 + # delete any password which may already be autocompleted + seq 20 | sed 's/.*/key --window '"$WINDOW"' BackSpace/g' | xdotool - + sleep 0.1 + echo "type --window $WINDOW $PASSWORD" | xdotool - +} + +case $USER in + login) + dologin + ;; + user) + dologin + ;; + fill) + dofill + echo "key --window $WINDOW KP_Enter" | xdotool - + ;; + filln) + dofill + ;; + show) + # user wants to display password instead + zenity --info --text "$PASSWORD" + ;; + *) + echo "type --window $WINDOW $PASSWORD" | xdotool - +esac