From 7696ea5ce8f662d99946e6ead4b63af6d7697e92 Mon Sep 17 00:00:00 2001 From: fbt Date: Tue, 25 Nov 2014 13:22:15 +0300 Subject: [PATCH] ugh, making this work with mimes is annoying --- sx-open | 17 +++++++---------- sx-open.cfg | 2 +- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/sx-open b/sx-open index a1215f0..994b675 100755 --- a/sx-open +++ b/sx-open @@ -41,20 +41,17 @@ main() { target="$1" [[ "$target" ]] || { usage; exit; } - if [[ "$target" =~ ${cfg_uri_regex} ]]; then - handle_uri "$target" - elif [[ -e "$target" ]]; then - [[ "$target" =~ ^/.* ]] || { target="${PWD}/${target}"; } + handle_uri "$target" || { + [[ "$target" =~ file://.+ ]] && { target="${target##*file://}"; } + + [[ -e "$target" ]] && { + [[ "$target" =~ ^/.* ]] || { target="${PWD}/${target}"; } - handle_uri "file://${target}" || { handle_mime "$target" } - else - echo "$target is not a uri nor is it an existing file. Bailing." - return 1 - fi + } - [[ "$?" -gt 0 ]] && { echo "No handlers found for $target"; } + [[ "$?" -gt 0 ]] && { echo "No handlers found for $target"; } return 0 } diff --git a/sx-open.cfg b/sx-open.cfg index 427fbb2..390f5bd 100644 --- a/sx-open.cfg +++ b/sx-open.cfg @@ -3,8 +3,8 @@ uri_handlers=( ["steam"]='^steam://.+' - ["browser"]='.+' ["javaws"]='^file:///.+?kvm.+?\.cgi$' + ["browser"]='^http(s)://.+' ) mime_handlers=(