browser (850B)
1 #!/usr/bin/env bash 2 3 default_browser=$(xdg-settings get default-web-browser) 4 5 if [ -z "$default_browser" ]; then 6 notify-send -u normal "Default Browser" "Default browser not set." 7 exit 1 8 fi 9 10 for path in /usr/local/share/applications /usr/share/applications ~/.local/share/applications; do 11 if [ -f "$path/$default_browser" ]; then 12 browser_path="$path/$default_browser" 13 break 14 fi 15 done 16 17 if [ -z "$browser_path" ]; then 18 notify-send -u normal "Default Browser" "Could not find .desktop file for default browser." 19 exit 1 20 fi 21 22 browser_command=$(grep -m 1 '^Exec=' "$browser_path" | sed 's/^Exec=//; s/ .*$//') 23 24 if [ -z "$browser_command" ]; then 25 notify-send -u normal "Default Browser" "Could not extract command from .desktop file." 26 exit 1 27 elif [ -n "$browser_command" ]; then 28 $browser_command & disown 29 fi