summary refs log tree commit diff
path: root/bin/urlopen
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2026-09-27 17:38:39 +0200
committerRobert Günzler <r@gnzler.io>2026-09-27 17:38:39 +0200
commit0860db73ae6fd9a6f6347219d820bf026a6b8b91 (patch)
tree11318c3670d1c32c5aa0bf404c22fba3bf63fc53 /bin/urlopen
parent4e34cbf9673aeaba252e01df554a0d204e83c5e2 (diff)
downloaddotfiles-0860db73ae6fd9a6f6347219d820bf026a6b8b91.tar.gz
Automated-commit-by: dots
Signed-off-by: Robert Günzler <r@gnzler.io>
Diffstat (limited to 'bin/urlopen')
-rwxr-xr-xbin/urlopen31
1 files changed, 19 insertions, 12 deletions
diff --git a/bin/urlopen b/bin/urlopen
index 2b0479c..0f2e6dd 100755
--- a/bin/urlopen
+++ b/bin/urlopen
@@ -14,7 +14,7 @@ main() {
 		fuzl_action_add "ask" "󰮫" "ask"
 		fuzl_action_add "clipboard" "󰅌" "clipboard"
 		fuzl_action_add "primary" "󱊁" "primary"
-		fuzl_action_menu "$(get_text "$*")"
+		fuzl_action_menu "$(get_text "$*")" || open_default "$(get_text "$*")"
 		;;
 	2)
 		local action
@@ -30,6 +30,8 @@ main() {
 # helpers
 #
 
+DEFAULT_BROWSER=librewolf.desktop
+
 get_text() {
 	local text="$*"
 	[ -z "$text" ] && read -r text
@@ -40,25 +42,30 @@ get_mimetype() {
 	local text=${1:?missing url}
 	case "$text" in
 	http*) printf %s 'x-scheme-handler/http' ;;
-	*) file -bdE --mime-type "$text" ;;
+	*) xdg-mime query filetype "$text" 2>/dev/null || file -bE --mime-type "$text" ;;
+	esac
+}
+get_x-scheme-handler_override() {
+	case "$1" in
+	slack.com) printf %s 'workfox.desktop' ;;
+	*) return 1 ;;
 	esac
 }
 open_default() {
 	local text=${1:?missing url}
 	local application
 	case "$(get_mimetype "$text")" in
-	x-scheme-handler/http*) application=librewolf ;;
+	x-scheme-handler/http*) application=$DEFAULT_BROWSER ;;
 	esac
-	case "$text" in
-	*linear.app*) application=linear ;;
-	*) application=librewolf ;;
-	esac
-	if [ -z "$application" ]; then
-		gio open "$text"
-	else
-		desktop_file=$(rg -Lil -e "$application" -- /usr/share/applications/ /var/lib/flatpak/exports/share/applications/ ~/.local/share/applications/ | tail -1)
-		gio launch "$desktop_file" "$text"
+	application_override=$(get_x-scheme-handler_override "$text" || :)
+	if [ -n "${application_override}" ]; then
+		application=$application_override
+	fi
+	if [ -n "${application:-}" ]; then
+		desktop_file=$(rg -Lil -g "$application" . -- /usr/share/applications/ /var/lib/flatpak/exports/share/applications/ ~/.local/share/applications/ | head -1)
+		exec gio launch "$desktop_file" "$text"
 	fi
+	exec gio open "$text"
 }
 #
 # actions