1
0
Fork 0
dotfiles/.local/bin/dmenuhandler

25 lines
1.5 KiB
Plaintext
Raw Normal View History

2022-07-04 21:36:33 +02:00
#!/bin/sh
# Feed this script a link and it will give dmenu
# some choice programs to use to open it.
2023-04-12 11:37:10 +02:00
feed="${1:-$(true | dmenu -p 'Paste URL or file path')}"
2022-07-04 21:36:33 +02:00
2023-02-04 22:15:35 +01:00
case "$(printf "copy url\\nsxiv\\nsetbg\\nPDF\\nbrowser\\nlynx\\nvim\\nmpv\\nmpv loop\\nmpv float\\nqueue download\\nqueue yt-dlp\\nqueue yt-dlp audio" | dmenu -i -p "Open it with?")" in
2023-02-07 17:19:53 +01:00
"copy url") echo "$feed" | xclip -selection clipboard ;;
mpv) setsid -f mpv -quiet "$feed" >/dev/null 2>&1 ;;
"mpv loop") setsid -f mpv -quiet --loop "$feed" >/dev/null 2>&1 ;;
"mpv float") setsid -f "$TERMINAL" -e mpv --geometry=+0-0 --autofit=30% --title="mpvfloat" "$feed" >/dev/null 2>&1 ;;
"queue yt-dlp") qndl "$feed" >/dev/null 2>&1 ;;
"queue yt-dlp audio") qndl "$feed" 'yt-dlp -o "%(title)s.%(ext)s" -f bestaudio --embed-metadata --restrict-filenames' ;;
"queue download") qndl "$feed" 'curl -LO' >/dev/null 2>&1 ;;
PDF) curl -sL "$feed" >"/tmp/$(echo "$feed" | sed "s|.*/||;s/%20/ /g")" && zathura "/tmp/$(echo "$feed" | sed "s|.*/||;s/%20/ /g")" >/dev/null 2>&1 ;;
sxiv) curl -sL "$feed" >"/tmp/$(echo "$feed" | sed "s|.*/||;s/%20/ /g")" && sxiv -a "/tmp/$(echo "$feed" | sed "s|.*/||;s/%20/ /g")" >/dev/null 2>&1 ;;
vim) curl -sL "$feed" >"/tmp/$(echo "$feed" | sed "s|.*/||;s/%20/ /g")" && setsid -f "$TERMINAL" -e "$EDITOR" "/tmp/$(echo "$feed" | sed "s|.*/||;s/%20/ /g")" >/dev/null 2>&1 ;;
setbg)
2024-01-02 19:09:46 +01:00
curl -L "$feed" >"$XDG_CACHE_HOME/pic"
xwallpaper --zoom "$XDG_CACHE_HOME/pic" >/dev/null 2>&1
;;
2023-02-07 17:19:53 +01:00
browser) setsid -f "$BROWSER" "$feed" >/dev/null 2>&1 ;;
lynx) lynx "$feed" >/dev/null 2>&1 ;;
2022-07-04 21:36:33 +02:00
esac