Skip to content

Commit

Permalink
Add support for firefox snap package (#291)
Browse files Browse the repository at this point in the history
- Closes #247
- Use snap directory in user's home
  as the profile directory
- Remove profile directories for firefox
  flatpak and snap, when deleting webapp
  • Loading branch information
hsbasu authored May 8, 2024
1 parent dc9db13 commit 2e52b7d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
15 changes: 12 additions & 3 deletions usr/lib/webapp-manager/common.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,13 @@ def wrapper(*args):
PROFILES_DIR = os.path.join(ICE_DIR, "profiles")
FIREFOX_PROFILES_DIR = os.path.join(ICE_DIR, "firefox")
FIREFOX_FLATPAK_PROFILES_DIR = os.path.expanduser("~/.var/app/org.mozilla.firefox/data/ice/firefox")
FIREFOX_SNAP_PROFILES_DIR = os.path.expanduser("~/snap/firefox/common/.mozilla/firefox")
LIBREWOLF_FLATPAK_PROFILES_DIR = os.path.expanduser("~/.var/app/io.gitlab.librewolf-community/data/ice/librewolf")
WATERFOX_FLATPAK_PROFILES_DIR = os.path.expanduser("~/.var/app/net.waterfox.waterfox/data")
EPIPHANY_PROFILES_DIR = os.path.join(ICE_DIR, "epiphany")
FALKON_PROFILES_DIR = os.path.join(ICE_DIR, "falkon")
ICONS_DIR = os.path.join(ICE_DIR, "icons")
BROWSER_TYPE_FIREFOX, BROWSER_TYPE_FIREFOX_FLATPAK, BROWSER_TYPE_LIBREWOLF_FLATPAK, BROWSER_TYPE_WATERFOX_FLATPAK, BROWSER_TYPE_CHROMIUM, BROWSER_TYPE_EPIPHANY, BROWSER_TYPE_FALKON = range(7)
BROWSER_TYPE_FIREFOX, BROWSER_TYPE_FIREFOX_FLATPAK, BROWSER_TYPE_FIREFOX_SNAP, BROWSER_TYPE_LIBREWOLF_FLATPAK, BROWSER_TYPE_WATERFOX_FLATPAK, BROWSER_TYPE_CHROMIUM, BROWSER_TYPE_EPIPHANY, BROWSER_TYPE_FALKON = range(8)

class Browser:

Expand Down Expand Up @@ -178,6 +179,7 @@ def get_supported_browsers():
Browser(BROWSER_TYPE_FIREFOX, "Firefox Extended Support Release", "firefox-esr", "/usr/bin/firefox-esr"),
Browser(BROWSER_TYPE_FIREFOX_FLATPAK, "Firefox (Flatpak)", "/var/lib/flatpak/exports/bin/org.mozilla.firefox", "/var/lib/flatpak/exports/bin/org.mozilla.firefox"),
Browser(BROWSER_TYPE_FIREFOX_FLATPAK, "Firefox (Flatpak)", ".local/share/flatpak/exports/bin/org.mozilla.firefox", ".local/share/flatpak/exports/bin/org.mozilla.firefox"),
Browser(BROWSER_TYPE_FIREFOX_SNAP, "Firefox (Snap)", "/snap/bin/firefox", "/snap/bin/firefox"),
Browser(BROWSER_TYPE_CHROMIUM, "Brave", "brave", "/usr/bin/brave"),
Browser(BROWSER_TYPE_CHROMIUM, "Brave Browser", "brave-browser", "/usr/bin/brave-browser"),
Browser(BROWSER_TYPE_CHROMIUM, "Brave (Bin)", "brave-bin", "/usr/bin/brave-bin"),
Expand Down Expand Up @@ -227,6 +229,8 @@ def get_supported_browsers():

def delete_webbapp(self, webapp):
shutil.rmtree(os.path.join(FIREFOX_PROFILES_DIR, webapp.codename), ignore_errors=True)
shutil.rmtree(os.path.join(FIREFOX_FLATPAK_PROFILES_DIR, webapp.codename), ignore_errors=True)
shutil.rmtree(os.path.join(FIREFOX_SNAP_PROFILES_DIR, webapp.codename), ignore_errors=True)
shutil.rmtree(os.path.join(PROFILES_DIR, webapp.codename), ignore_errors=True)
# first remove symlinks then others
if os.path.exists(webapp.path):
Expand Down Expand Up @@ -283,9 +287,14 @@ def create_webapp(self, name, url, icon, category, browser, custom_parameters, i
pass

def get_exec_string(self, browser, codename, custom_parameters, icon, isolate_profile, navbar, privatewindow, url):
if browser.browser_type in [BROWSER_TYPE_FIREFOX, BROWSER_TYPE_FIREFOX_FLATPAK]:
if browser.browser_type in [BROWSER_TYPE_FIREFOX, BROWSER_TYPE_FIREFOX_FLATPAK, BROWSER_TYPE_FIREFOX_SNAP]:
# Firefox based
firefox_profiles_dir = FIREFOX_PROFILES_DIR if browser.browser_type == BROWSER_TYPE_FIREFOX else FIREFOX_FLATPAK_PROFILES_DIR
if browser.browser_type == BROWSER_TYPE_FIREFOX:
firefox_profiles_dir = FIREFOX_PROFILES_DIR
elif browser.browser_type == BROWSER_TYPE_FIREFOX_FLATPAK:
firefox_profiles_dir = FIREFOX_FLATPAK_PROFILES_DIR
else:
firefox_profiles_dir = FIREFOX_SNAP_PROFILES_DIR
firefox_profile_path = os.path.join(firefox_profiles_dir, codename)
exec_string = ("sh -c 'XAPP_FORCE_GTKWINDOW_ICON=\"" + icon + "\" " + browser.exec_path +
" --class WebApp-" + codename +
Expand Down
4 changes: 2 additions & 2 deletions usr/lib/webapp-manager/webapp-manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from gi.repository import Gtk, Gdk, Gio, XApp, GdkPixbuf

# 3. Local application/library specific imports.
from common import _async, idle, WebAppManager, download_favicon, ICONS_DIR, BROWSER_TYPE_FIREFOX, BROWSER_TYPE_FIREFOX_FLATPAK
from common import _async, idle, WebAppManager, download_favicon, ICONS_DIR, BROWSER_TYPE_FIREFOX, BROWSER_TYPE_FIREFOX_FLATPAK, BROWSER_TYPE_FIREFOX_SNAP

setproctitle.setproctitle("webapp-manager")

Expand Down Expand Up @@ -452,7 +452,7 @@ def on_browser_changed(self, widget):

def show_hide_browser_widgets(self):
browser = self.browser_combo.get_model()[self.browser_combo.get_active()][BROWSER_OBJ]
if browser.browser_type == BROWSER_TYPE_FIREFOX or browser.browser_type == BROWSER_TYPE_FIREFOX_FLATPAK:
if browser.browser_type in [BROWSER_TYPE_FIREFOX, BROWSER_TYPE_FIREFOX_FLATPAK, BROWSER_TYPE_FIREFOX_SNAP]:
self.isolated_label.hide()
self.isolated_switch.hide()
self.navbar_label.show()
Expand Down

0 comments on commit 2e52b7d

Please sign in to comment.