aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-08-14 14:25:24 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-08-14 14:25:24 +1200
commit4c85039f0315132b96abc219fd49862ef4d195de (patch)
treef8b75fed64ce8a51cd706a783283e5629c15dbbd /bin
parentAdd urlh(1) and urlmt(1) (diff)
downloaddotfiles-4c85039f0315132b96abc219fd49862ef4d195de.tar.gz
dotfiles-4c85039f0315132b96abc219fd49862ef4d195de.zip
Add tentative enhancements to br(1)
Diffstat (limited to 'bin')
-rwxr-xr-xbin/br23
1 files changed, 22 insertions, 1 deletions
diff --git a/bin/br b/bin/br
index 1d982c04..e2a746c1 100755
--- a/bin/br
+++ b/bin/br
@@ -1,3 +1,24 @@
#!/bin/sh
-# Launch $BROWSER
+# 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/*)
+ 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
exec "$BROWSER" "$@"