diff options
author | ensa <psii@riseup.net> | 2020-07-08 15:32:24 -0700 |
---|---|---|
committer | ensa <psii@riseup.net> | 2020-07-08 15:32:24 -0700 |
commit | eec480ccb22f3166d723befc9522e8a25eabf8c1 (patch) | |
tree | 28ec200089f6d5797a06590defcb1c4ccf254c7c /bin/lh | |
parent | 4606fd8469199d5497b4b2fa4ea74d237ec9688b (diff) | |
download | cfg-eec480ccb22f3166d723befc9522e8a25eabf8c1.tar.gz |
catgirl-open.sh simplified, lh now handles stdin
bin/ bar.sh: doesn't specify width (defaults to display width) bother: incorrectly used last, now uses tail uses : instead of true (telling the shell to do nothing) catgirl-open.sh: tabbed now called with -c, network chosen before invoking tabbed just tests xprop instead of hacky $? handling comm-sel: no longer specifies config directory for cordless (cordless does this correctly now) lh: if no arguments are given, set $1 to standard input. turned actual link handling into a loop, lh can now be sent multiple links and handle them all in sequence.
Diffstat (limited to 'bin/lh')
-rwxr-xr-x | bin/lh | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/bin/lh b/bin/lh index 40d747d..331b358 100755 --- a/bin/lh +++ b/bin/lh @@ -2,6 +2,12 @@ # lh: the Link Handler # takes one path or URL as its argument, launches the appropriate program for it +# set argument 1 to stdin if there are no args +if [ $# -eq 0 ] +then + set -- "$(cat)" +fi + # if $1 isn't provided, spawn $BROWSER and exit. this allows lh to be used as a pseudo-browser. [ -z "$1" ] && exec "$BROWSER" #from pure-sh-bible @@ -43,6 +49,9 @@ findredir() { done } +# while loop for multiple urls +while [ $# -ne 0 ] +do # handle redirects. tr removes control characters, so the case statement below works as expected. URL=$(echo "$1"|findredir|tail -1|tr -d '[:cntrl:]') @@ -54,7 +63,7 @@ case "$URL" in $TERMINAL -e bombadillo "$URL" ;; *.mkv*|*.webm*|*.mp4*) mpv --no-terminal "$URL" & ;; - *youtube.com/watch*|*youtube.com/playlist*|*youtu.be*|*hooktube.com*|*bitchute.com*|*twitch.tv/videos/*|*twitch.tv/*/v/*) + *invidio.us/watch*|*youtube.com/watch*|*youtube.com/playlist*|*youtu.be*|*hooktube.com*|*bitchute.com*|*twitch.tv/videos/*|*twitch.tv/*/v/*) mpv --no-terminal --ytdl "$URL" & ;; *twitch.tv/*) STREAMQUAL="$(split "$(streamlink "$URL"|grep 'Available streams')" ", "|\ @@ -80,3 +89,5 @@ case "$URL" in $BROWSER "$URL" >/dev/null 2>&1 & fi ;; esac +shift +done |