diff options
Diffstat (limited to 'scripts/browser')
| -rwxr-xr-x | scripts/browser | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/scripts/browser b/scripts/browser new file mode 100755 index 0000000..3ed9494 --- /dev/null +++ b/scripts/browser @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +default_browser=$(xdg-settings get default-web-browser) + +if [ -z "$default_browser" ]; then + notify-send -u normal "Default Browser" "Default browser not set." + exit 1 +fi + +for path in /usr/local/share/applications /usr/share/applications ~/.local/share/applications; do + if [ -f "$path/$default_browser" ]; then + browser_path="$path/$default_browser" + break + fi +done + +if [ -z "$browser_path" ]; then + notify-send -u normal "Default Browser" "Could not find .desktop file for default browser." + exit 1 +fi + +browser_command=$(grep -m 1 '^Exec=' "$browser_path" | sed 's/^Exec=//; s/ .*$//') + +if [ -z "$browser_command" ]; then + notify-send -u normal "Default Browser" "Could not extract command from .desktop file." + exit 1 +elif [ -n "$browser_command" ]; then + $browser_command & disown +fi |
