46 lines
1.1 KiB
Bash
Executable File
46 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
CACHE=~/.cache/wpass-hist
|
|
|
|
set -e
|
|
|
|
shopt -s nullglob globstar
|
|
|
|
prefix=${PASSWORD_STORE_DIR-~/.password-store}
|
|
password_files=( "$prefix"/**/*.gpg )
|
|
password_files=( "${password_files[@]#"$prefix"/}" )
|
|
password_files=( "${password_files[@]%.gpg}" )
|
|
|
|
[ -f $CACHE ] || touch $CACHE
|
|
for line in $(cat $CACHE); do
|
|
password_files+=( $line )
|
|
done
|
|
|
|
entry=$(printf '%s\n' "${password_files[@]}" |
|
|
sort | uniq -c | sort -r |
|
|
sed 's/ *[0-9]* //'|
|
|
wdmenu -p Password $@)
|
|
|
|
[ -n "$entry" ] && echo "$entry" >> $CACHE || exit
|
|
|
|
username=$( pass show "$entry" 2>/dev/null | perl -ne 'print $1 if /^login: (.*)/' )
|
|
password=$( pass show "$entry" 2>/dev/null | head -n 1 )
|
|
|
|
action=$(echo -e "Autotype\nUsername -> $username\nPassword" | wdmenu -p Action)
|
|
|
|
sleep 1s
|
|
swaymsg input \* xkb_layout 'us'
|
|
|
|
case $action in
|
|
Autotype)
|
|
ydotool type "$username"
|
|
ydotool key tab
|
|
ydotool type "$password"
|
|
;;
|
|
Username*)
|
|
printf '%s' "$username" | wl-copy;;
|
|
Password)
|
|
printf '%s' "$password" | wl-copy;;
|
|
esac
|
|
|
|
swaymsg input \* xkb_layout 'br(dvorak)'
|