2021-01-23 22:46:24 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
if [ -t 1 ]; then
|
|
|
|
pick() {
|
|
|
|
sk
|
|
|
|
}
|
|
|
|
inject() {
|
|
|
|
echo "$@"
|
|
|
|
}
|
|
|
|
else
|
|
|
|
window="$(xdotool getwindowfocus)"
|
|
|
|
pick() {
|
|
|
|
dmenu -i -l 10
|
|
|
|
}
|
|
|
|
inject() {
|
|
|
|
xdotool type --clearmodifiers --window "$window" "$*"
|
|
|
|
xdotool windowfocus "$window"
|
|
|
|
}
|
|
|
|
fi
|
|
|
|
|
|
|
|
choice="$(pick <<HERE
|
|
|
|
email address
|
|
|
|
password
|
|
|
|
clipboard
|
|
|
|
selection
|
|
|
|
run
|
2021-03-16 10:50:03 +01:00
|
|
|
otp
|
|
|
|
student
|
2021-05-07 00:00:06 +02:00
|
|
|
curl
|
2021-06-16 11:30:34 +02:00
|
|
|
clipmenu
|
2021-01-23 22:46:24 +01:00
|
|
|
HERE
|
|
|
|
)"
|
|
|
|
|
|
|
|
case "$choice" in
|
|
|
|
'email address')
|
|
|
|
choice="$(khard email -p --remove-first-line | sed 's/\(.*\)\t\(.*\)\t\(.*\)/\2 <\1>/' | pick)"
|
|
|
|
inject "$choice"
|
|
|
|
;;
|
|
|
|
'password')
|
|
|
|
choice="$(cd ~/.password-store; find * -name '*.gpg' | sed 's/\.gpg$//' | sort -d | pick)"
|
2021-03-16 10:50:03 +01:00
|
|
|
inject "$(pass show "$choice" | head -1)"
|
2021-01-23 22:46:24 +01:00
|
|
|
;;
|
|
|
|
'clipboard')
|
|
|
|
inject "$(xclip -o -sel c)"
|
|
|
|
;;
|
|
|
|
'selection')
|
|
|
|
inject "$(xclip -o)"
|
|
|
|
;;
|
|
|
|
'run')
|
|
|
|
choice="$(dmenu_path | pick)"
|
|
|
|
exec "$choice"
|
|
|
|
;;
|
2021-03-16 10:50:03 +01:00
|
|
|
'otp')
|
|
|
|
choice="$(cd ~/.password-store/otp; find * -name '*.gpg' | sed 's/\.gpg$//' | sort -d | pick)"
|
|
|
|
inject "$(pass otp code otp/"$choice" | head -1)"
|
|
|
|
;;
|
|
|
|
'student')
|
2021-09-23 19:46:39 +02:00
|
|
|
choice="$(pick < ~/.local/share/students.list)"
|
2021-03-16 10:50:03 +01:00
|
|
|
inject "$choice"
|
|
|
|
;;
|
2021-05-07 00:00:06 +02:00
|
|
|
'curl')
|
|
|
|
d="$(mktemp -d)"
|
|
|
|
trap "rm -r '$d'" EXIT KILL
|
|
|
|
cd "$d"
|
|
|
|
curl -OJ "$(xclip -o)"
|
|
|
|
rifle -fF *
|
2021-06-16 11:30:34 +02:00
|
|
|
;;
|
|
|
|
'clipmenu')
|
|
|
|
exec clipmenu
|
|
|
|
;;
|
2021-01-23 22:46:24 +01:00
|
|
|
esac
|