[bin] Let xdg-open handle directories properly via browse-folder

This commit is contained in:
Sebastian Schulze 2022-01-18 23:19:39 +01:00
parent ee73697e7b
commit cf3cec4cc0
Signed by: bascht
GPG Key ID: 5BCB1D3B4D38A35A
1 changed files with 6 additions and 5 deletions

View File

@ -2,13 +2,14 @@
set -eo pipefail
argument=$1
url_regex='^(https?|mailto|ftp|file):/?/?.*'
# Strip file:// protocol as file -b will handle this
argument=$(echo $1 | sed "s|file://||")
url_regex='^(https?|mailto|ftp):/?/?.*'
if [[ $argument =~ $url_regex ]]; then
match=$argument
else
match=$(file -b --mime-type "${*}")
match=$(file -b --mime-type "${argument}")
fi;
echo "Searching for ${match} in handlers"
@ -17,8 +18,8 @@ case "${match}" in
*.slack.*)
exec qutebrowser-comms "$1"
;;
file://*)
exec nautilus "$1"
inode/directory)
exec browse-folder "$1"
;;
ssh:*)
host=$(echo $1 | cut -d "/" -f 3)