This repository has been archived on 2024-04-07. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles-old/scripts/.local/bin/wpass

46 lines
1.1 KiB
Plaintext
Raw Normal View History

2020-04-14 19:51:53 +02:00
#!/bin/bash
2020-04-17 06:54:35 +02:00
CACHE=~/.cache/wpass-hist
2020-04-14 19:51:53 +02:00
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
2020-04-22 00:36:45 +02:00
password_files+=( $line )
2020-04-14 19:51:53 +02:00
done
entry=$(printf '%s\n' "${password_files[@]}" |
2020-04-28 00:13:01 +02:00
sort | uniq -c | sort -r |
sed 's/ *[0-9]* //'|
2020-04-28 00:24:16 +02:00
wdmenu -p Password $@)
2020-04-14 19:51:53 +02:00
[ -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 )
2020-05-22 02:34:08 +02:00
action=$(echo -e "Autotype\nUsername -> $username\nPassword" | wdmenu -p Action)
2020-06-16 21:58:16 +02:00
sleep 1s
2020-05-22 02:34:08 +02:00
swaymsg input \* xkb_layout 'us'
case $action in
2020-04-14 19:51:53 +02:00
Autotype)
ydotool type "$username"
ydotool key tab
ydotool type "$password"
;;
Username*)
printf '%s' "$username" | wl-copy;;
Password)
printf '%s' "$password" | wl-copy;;
esac
2020-05-22 02:34:08 +02:00
swaymsg input \* xkb_layout 'br(dvorak)'