113 lines
2.1 KiB
Bash
Executable File
113 lines
2.1 KiB
Bash
Executable File
#!/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
|
|
pass
|
|
lpass
|
|
clipboard
|
|
selection
|
|
run
|
|
otp
|
|
student
|
|
curl
|
|
clipmenu
|
|
yubikey
|
|
emoji
|
|
spotify-title
|
|
youtube-dl
|
|
audio-dl
|
|
HERE
|
|
)"
|
|
|
|
case "$choice" in
|
|
'email address')
|
|
choice="$(khard email -p --remove-first-line | sed 's/\(.*\)\t\(.*\)\t\(.*\)/\2 <\1>/' | pick)"
|
|
inject "$choice"
|
|
;;
|
|
'pass')
|
|
choice="$(cd ~/.password-store; find * -name '*.gpg' | sed 's/\.gpg$//' | sort -d | pick)"
|
|
inject "$(pass show "$choice" | head -1)"
|
|
;;
|
|
'lpass')
|
|
choice="$(lpass ls --format '%an' --color=never | grep -v '^$' | pick)"
|
|
inject "$(lpass show --password "$choice" | head -1)"
|
|
;;
|
|
'clipboard')
|
|
inject "$(xclip -o -sel c)"
|
|
;;
|
|
'selection')
|
|
inject "$(xclip -o)"
|
|
;;
|
|
'run')
|
|
choice="$(dmenu_path | pick)"
|
|
exec "$choice"
|
|
;;
|
|
'otp')
|
|
choice="$(cd ~/.password-store/otp; find * -name '*.gpg' | sed 's/\.gpg$//' | sort -d | pick)"
|
|
inject "$(pass otp code otp/"$choice" | head -1)"
|
|
;;
|
|
'student')
|
|
choice="$(pick < ~/.local/share/students.list)"
|
|
inject "$choice"
|
|
;;
|
|
'curl')
|
|
d="$(mktemp -d)"
|
|
trap "rm -r '$d'" EXIT KILL
|
|
cd "$d"
|
|
curl -LOJ "$(xclip -o)"
|
|
rifle -fF *
|
|
;;
|
|
'clipmenu')
|
|
exec clipmenu
|
|
;;
|
|
'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##* }"
|
|
;;
|
|
'spotify-title')
|
|
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 *
|
|
;;
|
|
esac
|