diff options
author | sinanmohd <sinan@firemail.cc> | 2023-09-22 10:21:11 +0530 |
---|---|---|
committer | sinanmohd <sinan@firemail.cc> | 2023-09-22 10:21:11 +0530 |
commit | 9c7fccfc94b4e8156ed02b11f7847410fd02b8e2 (patch) | |
tree | c31b6cc0efc56f17169f2c369ae2cb74a41589e5 | |
parent | 7f54ed1cbc9e0c6ae41ece401194ccee0f65e5af (diff) |
bin/linkhandler: clean up
-rwxr-xr-x | .local/bin/linkhandler | 69 |
1 files changed, 34 insertions, 35 deletions
diff --git a/.local/bin/linkhandler b/.local/bin/linkhandler index fb8d071..a4904e1 100755 --- a/.local/bin/linkhandler +++ b/.local/bin/linkhandler @@ -6,40 +6,39 @@ note() notify-send " linkhandler" "$1" } -main() -{ - [ -z "$1" ] && - exec "${BROWSER:-firefox}" +######## +# MAIN # +######## - 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 & - ;; - *.c|*.cpp|*.sh|*.txt|*.java|*.nix|*.lua) - note "processing text" - 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 & - ;; - *) - if echo "$1" | grep -Eqx '^https?://[^/]*\.onion(/.*)?'; then - if ! command -v tor-browser > /dev/null; then - note "tor browser not installed" - exit 1 - fi - exec tor-browser "$1" >/dev/null 2>&1 - else - exec "$BROWSER" "$1" >/dev/null 2>&1 - fi - ;; - esac -} +[ -z "$1" ] && + exec "${BROWSER:-firefox}" -main "$@" +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 & + ;; +*.c|*.cpp|*.sh|*.txt|*.java|*.nix|*.lua) + note "processing text" + 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 & + ;; +*) + if echo "$1" | grep -Eqx '^https?://[^/]*\.onion(/.*)?'; then + if ! command -v tor-browser > /dev/null; then + note "tor browser not installed" + exit 1 + fi + exec tor-browser "$1" >/dev/null 2>&1 + else + exec "$BROWSER" "$1" >/dev/null 2>&1 + fi + ;; +esac |