major fixes
This commit is contained in:
parent
749eb9a5c4
commit
2e4961ee0a
|
@ -1,45 +1,43 @@
|
|||
#!/bin/bash
|
||||
CACHE=~/.cache/wpass-hist
|
||||
|
||||
set -e
|
||||
|
||||
shopt -s nullglob globstar
|
||||
|
||||
prefix=${PASSWORD_STORE_DIR-~/.password-store}
|
||||
password_files=( "$prefix"/**/*.gpg )
|
||||
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[@]}" | wdmenu -p Password $@)
|
||||
|
||||
entry=$(printf '%s\n' "${password_files[@]}" |
|
||||
sort | uniq -c | sort -r |
|
||||
sed 's/ *[0-9]* //'|
|
||||
wdmenu -p Password $@)
|
||||
|
||||
[ -n "$entry" ] && echo "$entry" >> $CACHE || exit
|
||||
[ -n "$entry" ] || 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'
|
||||
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
|
||||
ydotool --delay 1 key {{@@ key.insertMode @@}}
|
||||
fi
|
||||
ydotool type "$username"
|
||||
ydotool key tab
|
||||
ydotool type "$password"
|
||||
|
||||
[ -n "$restoreKeyLayout" ] &&
|
||||
swaymsg input \* xkb_layout "$restoreKeyLayout"
|
||||
}
|
||||
|
||||
case $action in
|
||||
Autotype)
|
||||
if [ $(swaymsg -t get_tree | jq -r '.. | select(.focused? == true).app_id') = "org.qutebrowser.qutebrowser" ]
|
||||
then
|
||||
ydotool key esc
|
||||
ydotool key {{@@ key.insertMode @@}}
|
||||
fi
|
||||
ydotool type "$username"
|
||||
ydotool key tab
|
||||
ydotool type "$password"
|
||||
autotype
|
||||
;;
|
||||
Username*)
|
||||
printf '%s' "$username" | wl-copy;;
|
||||
|
@ -47,4 +45,3 @@ case $action in
|
|||
printf '%s' "$password" | wl-copy;;
|
||||
esac
|
||||
|
||||
swaymsg input \* xkb_layout 'us(colemak)'
|
||||
|
|
Reference in New Issue