diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2016-08-14 21:18:45 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2016-08-14 21:18:45 +1200 |
commit | 974da7f15d5f8c50ca9b42a16f5a590704d0aa3a (patch) | |
tree | 826cd3034e3900a17208120cebc5ec71aaad1073 /bin | |
parent | Remove unneeded options from dmenu_run (diff) | |
download | dotfiles-974da7f15d5f8c50ca9b42a16f5a590704d0aa3a.tar.gz dotfiles-974da7f15d5f8c50ca9b42a16f5a590704d0aa3a.zip |
Refactor br(1), brxs(1), add xgo(1) and xgoc(1)
Including updating keybindings
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/br | 24 | ||||
-rwxr-xr-x | bin/brxs | 3 | ||||
-rwxr-xr-x | bin/xgo | 33 | ||||
-rw-r--r-- | bin/xgoc | 3 |
4 files changed, 37 insertions, 26 deletions
@@ -1,25 +1,3 @@ #!/bin/sh -# Probably launch $BROWSER, but try a few shortcuts first - -# Get the URL and its MIME type -url=$1 -mt=$(urlmt "$url") - -# If the MIME type is an image, load it in feh(1) -case $mt in - image/gif) ;; - image/*) - curl -- "$url" | feh - && exit - ;; -esac - -# If it's a YouTube video without a given start time, load it in mpv(1) -case $url in - *youtube.com/watch*[?\&]t=) ;; - *youtube.com/watch*) - mpv -- "$url" && exit - ;; -esac - -# Otherwise, just ask $BROWSER to handle it +# Just launch $BROWSER with any given arguments exec "$BROWSER" "$@" diff --git a/bin/brxs b/bin/brxs deleted file mode 100755 index 5324885d..00000000 --- a/bin/brxs +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -# Run $BROWSER with an URL retrieved from X's PRIMARY select -exec br "$(xsel)" diff --git a/bin/xgo b/bin/xgo new file mode 100755 index 00000000..56bbb0f9 --- /dev/null +++ b/bin/xgo @@ -0,0 +1,33 @@ +#!/bin/sh +# Test and open a clipboard URL with an apt program + +# Check arguments +if [ "$#" -eq 0 ] ; then + printf 2>&1 'xgo: At least one URL required\n' +fi + +# Iterate over the URL arguments +for url ; do ( + + # If it's a YouTube video without a given start time, load it in mpv(1) + case $url in + *youtube.com/watch*[?\&]t=) ;; + *youtube.com/watch*) + mpv -- "$url" && continue + ;; + esac + + # If the MIME type is an image, load it in feh(1) + case $mt in + image/gif) ;; + image/*) + curl -- "$url" | feh - && continue + ;; + esac + + # Get the MIME type data + mt=$(urlmt "$url") + + # Otherwise, just pass it to br(1) + br "$url" +) & done diff --git a/bin/xgoc b/bin/xgoc new file mode 100644 index 00000000..9e4b0929 --- /dev/null +++ b/bin/xgoc @@ -0,0 +1,3 @@ +#!/bin/sh +# Run xgo(1) with the contents of the X clipboard +xgo "$(xsel)" |