urxvt => termite; rofi-pass autotypes user/pass into browser (if active)

This commit is contained in:
Henrik Lissner 2016-11-05 01:51:45 +01:00
parent e7c4e84003
commit c4e85ca629
4 changed files with 35 additions and 31 deletions

View file

@ -4,7 +4,7 @@
# terminal emulator # terminal emulator
super + ctrl + Return super + ctrl + Return
urxvt termite
# scratchpad # scratchpad
super + grave super + grave
@ -15,12 +15,9 @@ super + grave
# program launcher # program launcher
super + space super + space
rofi -show run rofi -show run
# switch to desktop
super + shift + space
rofi_bspwm.sh
# password manager # password manager
super + alt + space super + alt + backslash
rofi_pass.sh rofi-pass
# make sxhkd reload its configuration files: # make sxhkd reload its configuration files:
super + Escape super + Escape

32
os/arch/bin/rofi-pass Executable file
View file

@ -0,0 +1,32 @@
#!/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[@]}" | rofi -dmenu -p pass: "$@")
[[ -n $password ]] || exit
for browser in firefox chromium
do
wid=$(xdotool search --onlyvisible --name "$browser")
[[ $wid ]] && break
done
# If browser is in focus, type it in
if [[ $wid = $(xdotool getwindowfocus) ]]
then
data="$(pass show "$password")"
pass="$(echo "$data" | head -1)"
login="$(echo "$data" | grep "^login:" | awk '{print $2}')"
xdotool type --clearmodifiers "$login"
xdotool key Tab
xdotool type --clearmodifiers "$pass"
else
pass show -c "$password" 2>/dev/null
fi

View file

@ -1,25 +0,0 @@
#!/usr/bin/env bash
shopt -s nullglob globstar
typeit=0
if [[ $1 == "--type" ]]; then
typeit=1
shift
fi
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[@]}" | rofi -dmenu -p pass: "$@")
[[ -n $password ]] || exit
if [[ $typeit -eq 0 ]]; then
pass show -c "$password" 2>/dev/null
else
pass show "$password" | { read -r pass; printf %s "$pass"; } |
xdotool type --clearmodifiers --file -
fi