51 lines
860 B
Bash
51 lines
860 B
Bash
#!/usr/bin/env bash
|
|
|
|
set -eo pipefail
|
|
|
|
argument=$1
|
|
url_regex='^(https?|mailto|ftp|file):/?/?.*'
|
|
|
|
if [[ $argument =~ $url_regex ]]; then
|
|
match=$argument
|
|
else
|
|
match=$(file -b --mime-type "${*}")
|
|
fi;
|
|
|
|
echo "Searching for ${match} in handlers"
|
|
|
|
case "${match}" in
|
|
*.slack.*)
|
|
exec qutebrowser-comms "$1"
|
|
;;
|
|
file://*)
|
|
exec nautilus "$1"
|
|
;;
|
|
ssh:*)
|
|
host=$(echo $1 | cut -d "/" -f 3)
|
|
exec foot ssh "$host"
|
|
;;
|
|
text/html|http://*|https://*)
|
|
exec firefox "$1"
|
|
;;
|
|
application/x-postscript|image/x-eps|application/pdf)
|
|
exec zathura "$1"
|
|
;;
|
|
image/gif|video/*)
|
|
exec mpv --loop=inf "$1"
|
|
;;
|
|
image/*)
|
|
exec imv "$1"
|
|
;;
|
|
atom://*)
|
|
exec atom "$1"
|
|
;;
|
|
text/x-tex|text/plain|mailto://*)
|
|
exec em "$1"
|
|
;;
|
|
*)
|
|
notify-send "${0}" "Don't know how to open ${@} of type ${match}" -t 2500 >&2
|
|
exec foot --app-id 'files' ranger $@
|
|
;;
|
|
esac
|
|
|