432966a418
* copy URLs in foot to primary selection * remove rarely used/invalid choices from delegator * manually exit in mailsync because ! disabled set -e * emit OSC 7 cwd so foot can open new windows in current directory
104 lines
2.0 KiB
Bash
Executable File
104 lines
2.0 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
if [ -t 1 -a "$1" != '-g' ]; then
|
|
pick() {
|
|
sk
|
|
}
|
|
inject() {
|
|
echo "$@"
|
|
}
|
|
else
|
|
pick() {
|
|
if pgrep wayland >/dev/null; then
|
|
skmenu
|
|
else
|
|
dmenu -i -l 10
|
|
fi
|
|
}
|
|
inject() {
|
|
if pgrep wayland >/dev/null; then
|
|
wtype -s 500 "$*"
|
|
else
|
|
window="$(xdotool getwindowfocus)"
|
|
xdotool type --clearmodifiers --window "$window" "$*"
|
|
xdotool windowfocus "$window"
|
|
fi
|
|
}
|
|
fi
|
|
|
|
if wl-paste -h >/dev/null; then
|
|
primary() { wl-paste --primary; }
|
|
clip() { wl-paste; }
|
|
else
|
|
primary() { xclip -o; }
|
|
clip() { xclip -o -sel c; }
|
|
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 "$(clip)"
|
|
;;
|
|
'selection')
|
|
inject "$(primary)"
|
|
;;
|
|
'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)"
|
|
;;
|
|
'curl')
|
|
d="$(mktemp -d)"
|
|
trap "rm -r '$d'" EXIT KILL
|
|
cd "$d"
|
|
curl -LOJ "$(primary)"
|
|
rifle -fF *
|
|
;;
|
|
'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 "$(clip)" | sed -n 's@.*<title>\(.*\) - song \(and lyrics \)\?by \(.*\) | Spotify</title>.*@\1 _van_ \3@p')"
|
|
;;
|
|
esac
|