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
|
2022-05-09 17:18:15 +02:00
|
|
|
pass
|
|
|
|
lpass
|
2021-01-23 22:46:24 +01:00
|
|
|
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
|
2022-05-09 17:18:15 +02:00
|
|
|
yubikey
|
|
|
|
emoji
|
2022-05-16 15:47:50 +02:00
|
|
|
spotify-title
|
2022-09-20 15:53:09 +02:00
|
|
|
youtube-dl
|
|
|
|
audio-dl
|
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"
|
|
|
|
;;
|
2022-05-09 17:18:15 +02:00
|
|
|
'pass')
|
2021-01-23 22:46:24 +01:00
|
|
|
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
|
|
|
;;
|
2022-05-09 17:18:15 +02:00
|
|
|
'lpass')
|
|
|
|
choice="$(lpass ls --format '%an' --color=never | grep -v '^$' | pick)"
|
|
|
|
inject "$(lpass show --password "$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"
|
2022-01-04 00:24:36 +01:00
|
|
|
curl -LOJ "$(xclip -o)"
|
2021-05-07 00:00:06 +02:00
|
|
|
rifle -fF *
|
2021-06-16 11:30:34 +02:00
|
|
|
;;
|
|
|
|
'clipmenu')
|
|
|
|
exec clipmenu
|
|
|
|
;;
|
2022-05-09 17:18:15 +02:00
|
|
|
'yubikey')
|
|
|
|
choice="$(ykman oath accounts list | pick)"
|
|
|
|
inject "$(ykman oath accounts code -s "$choice")"
|
|
|
|
;;
|
|
|
|
'emoji')
|
|
|
|
choice="$(uni emoji all -f '%(name), %(cldr_full), %(emoji)' | awk -F', ' '{ i=1; while($i != $NF && $i != "") { print($i, $NF); i++ }}' | pick)"
|
|
|
|
inject "${choice##* }"
|
|
|
|
;;
|
2022-05-16 15:47:50 +02:00
|
|
|
'spotify-title')
|
2022-09-20 15:53:09 +02:00
|
|
|
inject "$(curl -L "$(xclip -o)" | sed -n 's@.*<title>\(.*\) - song \(and lyrics \)\?by \(.*\) | Spotify</title>.*@\1 - \3@p')"
|
|
|
|
;;
|
|
|
|
'youtube-dl')
|
|
|
|
d="$(mktemp -d)"
|
|
|
|
trap "rm -r '$d'" EXIT KILL
|
|
|
|
cd "$d"
|
|
|
|
yt-dlp "$(xclip -o)"
|
|
|
|
if mplayer -v >/dev/null; then
|
|
|
|
exec st mplayer *
|
|
|
|
else
|
|
|
|
exec st mpv *
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
'audio-dl')
|
|
|
|
d="$(mktemp -d)"
|
|
|
|
trap "rm -r '$d'" EXIT KILL
|
|
|
|
cd "$d"
|
|
|
|
yt-dlp -x "$(xclip -o)"
|
|
|
|
exec st mpv --no-video *
|
2022-05-16 15:47:50 +02:00
|
|
|
;;
|
2021-01-23 22:46:24 +01:00
|
|
|
esac
|