💾 Archived View for ait.place › dot › bin › .local › bin › dhandler.txt captured on 2021-12-03 at 14:04:38.
-=-=-=-=-=-=-
#!/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 case "$(printf "mpv\\nmpvhome\\nyoutube-dl\\nyoutube-mpv\\naudio\\ndownload\\nfeh\\nbrowser\\ntransadd\\ncopy" | dmenu -i)" in mpv) setsid mpv "$url" >/dev/null 2>&1 & ;; mpvhome) $TERMINAL -e mpvhome "$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 ;; youtube-mpv) setsid $TERMINAL -e youtube-dl -ic -o "$XDG_VIDEOS_DIR/mpv/%(title)s.%(ext)s" --exec mpv "$url" >/dev/null 2>&1 ;; audio) setsid $TERMINAL -e youtube-dl -f bestaudio -ic "$url" --exec mpv >/dev/null 2>&1 ;; download) curl -LO "$url" >/dev/null 2>&1 ;; feh) setsid feh "$url" >/dev/null 2>&1 & ;; browser) setsid "$BROWSER" "$url" >/dev/null 2>&1 & ;; transadd) transadd "$url" >/dev/null 2>&1 & ;; copy) echo "$url" | xclip -selection clipboard ;; esac