#!/bin/bash

# Copyright 2024-2025 Zorin OS Technologies Ltd.
#
# This program is free software you can redistribute it and/or modify it
# under the terms and conditions of the GNU General Public License,
# version 3, as published by the Free Software Foundation.
#
# This program is distributed in the hope it will be useful, but WITHOUT ANY
# WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
# more details.

if [[ -e /usr/share/applications/brave-browser.desktop ]]; then
	xdg-settings set default-web-browser brave-browser.desktop
elif [[ -e /usr/share/applications/firefox.desktop ]]; then
	xdg-settings set default-web-browser firefox.desktop
	sed -i 's/brave-browser/firefox/g' ~/.config/xfce4/panel/docklike-3.rc
elif [[ -e /var/lib/flatpak/exports/share/applications/org.mozilla.firefox.desktop ]]; then
	xdg-settings set default-web-browser org.mozilla.firefox.desktop
	sed -i 's/brave-browser/org.mozilla.firefox/g' ~/.config/xfce4/panel/docklike-3.rc
fi

if [[ -e ~/.config/autostart/zorin-default-browser-autostart.desktop ]]; then
	rm ~/.config/autostart/zorin-default-browser-autostart.desktop
fi
