2020-04-14 19:51:53 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
shopt -s nullglob globstar
|
|
|
|
|
2020-10-20 18:54:12 +02:00
|
|
|
INSERTKEY="{{@@ key.insertMode @@}}"
|
|
|
|
#{%@@ if False @@%}#
|
|
|
|
INSERTKEY="i"
|
|
|
|
#{%@@ endif @@%}#
|
|
|
|
|
2020-04-14 19:51:53 +02:00
|
|
|
prefix=${PASSWORD_STORE_DIR-~/.password-store}
|
2020-10-03 06:02:50 +02:00
|
|
|
password_files=( "$prefix"/**/*.gpg )
|
2020-04-14 19:51:53 +02:00
|
|
|
password_files=( "${password_files[@]#"$prefix"/}" )
|
|
|
|
password_files=( "${password_files[@]%.gpg}" )
|
|
|
|
|
2020-10-03 01:24:04 +02:00
|
|
|
entry=$(printf '%s\n' "${password_files[@]}" | wdmenu -p Password $@)
|
2020-04-14 19:51:53 +02:00
|
|
|
|
2020-10-03 01:24:04 +02:00
|
|
|
[ -n "$entry" ] || exit
|
2020-04-14 19:51:53 +02:00
|
|
|
|
|
|
|
username=$( pass show "$entry" 2>/dev/null | perl -ne 'print $1 if /^login: (.*)/' )
|
|
|
|
password=$( pass show "$entry" 2>/dev/null | head -n 1 )
|
|
|
|
|
2020-10-06 01:58:06 +02:00
|
|
|
action=$(printf "Autotype\nUsername -> $username\nPassword" | wdmenu -p Action)
|
2020-05-22 02:34:08 +02:00
|
|
|
|
2020-10-03 01:24:04 +02:00
|
|
|
autotype(){
|
|
|
|
if swaymsg -t get_inputs | grep -i colemak > /dev/null
|
|
|
|
then
|
|
|
|
swaymsg input \* xkb_layout 'us'
|
|
|
|
restoreKeyLayout='us(colemak)'
|
|
|
|
fi
|
|
|
|
if [ $(swaymsg -t get_tree | jq -r '.. | select(.focused? == true).app_id') = "org.qutebrowser.qutebrowser" ]
|
|
|
|
then
|
|
|
|
ydotool --delay 1 key esc
|
2020-10-20 18:54:12 +02:00
|
|
|
ydotool --delay 1 key "$INSERTKEY"
|
2020-10-03 01:24:04 +02:00
|
|
|
fi
|
2020-10-18 18:38:52 +02:00
|
|
|
ydotool type --delay 100 "$username"
|
2020-10-03 01:24:04 +02:00
|
|
|
ydotool key tab
|
2020-10-18 18:38:52 +02:00
|
|
|
ydotool type --delay 100 "$password"
|
2020-10-03 01:24:04 +02:00
|
|
|
|
|
|
|
[ -n "$restoreKeyLayout" ] &&
|
|
|
|
swaymsg input \* xkb_layout "$restoreKeyLayout"
|
|
|
|
}
|
2020-05-22 02:34:08 +02:00
|
|
|
|
|
|
|
case $action in
|
2020-04-14 19:51:53 +02:00
|
|
|
Autotype)
|
2020-10-03 01:24:04 +02:00
|
|
|
autotype
|
2020-04-14 19:51:53 +02:00
|
|
|
;;
|
|
|
|
Username*)
|
|
|
|
printf '%s' "$username" | wl-copy;;
|
|
|
|
Password)
|
|
|
|
printf '%s' "$password" | wl-copy;;
|
|
|
|
esac
|
2020-05-22 02:34:08 +02:00
|
|
|
|