THEAARBS menus - handler menu

Raw

#!/bin/sh
# Feed this script a URL and choose what opens it

MenuChoices=\
"$READER
$IMGVIEWER
$BROWSER
w3m
mpv
mpv (loop)
mpv (float)
wget
stream-dl
bandcamp-dl"

case $(tty) in
    *tty*)   runprefix="$TERMINAL -e" ;;
    *)   runprefix= ;;
esac

if [ -z $1 ] ; then url=$(inprompt "URL:") || exit
else url=$1 ; fi

handle_url() {
    choice=$(echo -e "$MenuChoices" | dwmenu Handler) || exit
    case "$choice" in
        "$READER") $runprefix $READER "$1" &disown ;;
        "IMGVIEWER")  $IMGVIEWER "$1" &disown ;;
        "$BROWSER")    $BROWSER "$1" & disown ;;
        w3m)     $runprefix w3m "$1" ;;
        mpv)     mpv -quiet "$1" & disown ;;
        "mpv (loop)") mpv -quiet --loop "$1" & disown ;;
        "mpv (float)")    mpv --geometry=+0-0 --autofit=30%  --title="mpvfloat" /dev/video0 "$1" & disown ;;
        wget)        wget "$1" & disown ;;
        stream-dl)   youtube-dl "$1" & disown ;;
        bandcamp-dl) cd ~/Downloads
                bandcamp-dl "$1" >/dev/null &&
                notify-send "👍 Finished downloading" "$(basename $1)" ||
                notify-send "⛔ Error downloading" "$(basename $1)" ;;
    esac ;}

handle_url $url

categories · links · piano · posts · scripts · THEAARBS · home