url_handler.sh 769 B

12345678910111213141516171819202122232425262728
  1. #!/bin/bash
  2. # thanks to Luke Smith
  3. # https://github.com/LukeSmithxyz
  4. # Feed script a url.
  5. # If an image, it will view in feh,
  6. # if a video or gif, it will view in mpv
  7. # if a music file or pdf, it will download,
  8. # otherwise it opens link in browser.
  9. ext="${1##*.}"
  10. mpvFiles="mkv mp4 gif webm"
  11. fehFiles="png jpg jpeg jpe"
  12. wgetFiles="mp3 flac opus mp3?source=feed pdf"
  13. if echo $fehFiles | grep -w $ext > /dev/null; then
  14. feh "$1" >/dev/null & disown
  15. # elif echo $mpvFiles | grep -w $ext > /dev/null; then
  16. # mpv -quiet "$1" > /dev/null & disown
  17. elif echo $wgetFiles | grep -w $ext > /dev/null; then
  18. wget "$1" >/dev/null & disown
  19. # elif echo "$@" | grep "$vidsites">/dev/null; then
  20. # mpv -quiet "$1" > /dev/null & disown
  21. else
  22. firefox "$1" 2>/dev/null & disown
  23. fi