diff options
author | sinanmohd <pcmsinan@gmail.com> | 2023-03-11 14:21:21 +0530 |
---|---|---|
committer | sinanmohd <pcmsinan@gmail.com> | 2023-03-11 14:21:21 +0530 |
commit | 8fa5760c5e48281150c00afb1586f3d7673f3631 (patch) | |
tree | 64ee93f40602878fcb8740f322304adbd7ec260a /.local/bin/linkhandler | |
parent | 84a19710ae73e95662ad7478e8059c3d2bf22b4f (diff) |
bin: linkhandler: import from old dot files
Diffstat (limited to '.local/bin/linkhandler')
-rwxr-xr-x | .local/bin/linkhandler | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/.local/bin/linkhandler b/.local/bin/linkhandler new file mode 100755 index 0000000..f641419 --- /dev/null +++ b/.local/bin/linkhandler @@ -0,0 +1,37 @@ +#!/bin/sh + +note() +{ + command -v notify-send > /dev/null && + notify-send " linkhandler" "$1" +} + +main() +{ + [ -z "$1" ] && + exec "${BROWSER:-firefox}" + + case "$1" in + *mp3|*flac|*opus|*mkv|*webm|*mp4|*youtube.com/watch*|\ + *youtube.com/playlist*|*youtu.be*|*bitchute.com*|*videos.lukesmith.xyz*|\ + *piped.kavin.rocks*|*inv.vern.cc*|*yewtu.be*) + note "streaming media" + exec mpv -quiet "$1" > /dev/null 2>&1 + ;; + *.png|*.jpg|*.jpeg|*.gif|*.webp|*.pdf|*.cbz|*.cbr) + note "processing file" + curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" && + exec xdg-open "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" > /dev/null 2>&1 & + ;; + *.cpp|*.c|*.sh|*.txt) + note "processing text" + curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" && + exec "$TERMINAL" -e xdg-open "/tmp/$(echo "$1" | sed "s/.*\///;s/%20/ /g")" > /dev/null 2>&1 & + ;; + *) + exec "$BROWSER" "$1" >/dev/null 2>&1 + ;; + esac +} + +main "$@" |