💾 Archived View for ait.place › dot › bin › dhandler.txt captured on 2023-01-29 at 03:29:09.
⬅️ Previous capture (2022-07-16)
-=-=-=-=-=-=-
#!/bin/sh # Feed this script a link and it will give dmenu # some choice programs to use to open it. # You cant overwrite $1, so make a new variable url=$1 # Reads form stdin if - is first argument or empty if [ -z "$url" ] || [ "$url" = "-" ] ; then if [ -t 0 ]; then url="$(xclip -selection c -o)" else url="$(cat /dev/stdin)" fi # if stdin empty then exit [ -z "$url" ] && exit 255 fi choices=" mpv webtorrent youtube-dl audio browser transadd copy " case "$(echo $choices | tr ' ' '\n' | dmenu -i)" in mpv) setsid mpv "$url" >/dev/null 2>&1 & ;; webtorrent) webtorrent --mpv "$url" >/dev/null 2>&1 & ;; youtube-dl) setsid $TERMINAL -e youtube-dl -ic -o "$XDG_VIDEOS_DIR/mpv/%(title)s.%(ext)s" "$url" >/dev/null 2>&1 &;; audio) setsid $TERMINAL -e youtube-dl -f bestaudio -ic "$url" --exec mpv >/dev/null 2>&1 & ;; browser) setsid "$BROWSER" "$url" >/dev/null 2>&1 & ;; transadd) transmission-remote -a "$url" >/dev/null 2>&1 & ;; copy) echo "$url" | xclip -selection clipboard ;; esac