1
0
Fork
You've already forked activity-aware-firefox
0
Integration of Firefox into KDE Plasma in a way that it plays nice with its Activities. This is a fork of https://gitlab.com/hook/activity-aware-firefox/
  • Shell 71.9%
  • CSS 28.1%
Find a file
2021年06月04日 11:34:15 +02:00
LICENSES Make repository REUSE compliant 2021年06月02日 21:11:52 +02:00
.gitignore Make repository REUSE compliant 2021年06月02日 21:11:52 +02:00
.gitlab-ci.yml Rename CI file, to comply with GitLab’s strictness 2021年06月02日 21:14:51 +02:00
activityfirefox Make repository REUSE compliant 2021年06月02日 21:11:52 +02:00
activityfirefox.desktop Make repository REUSE compliant 2021年06月02日 21:11:52 +02:00
README.markdown Add tip on how to migrate loads of tabs 2021年06月04日 11:34:15 +02:00
userChrome.css Make repository REUSE compliant 2021年06月02日 21:11:52 +02:00

Activity-aware Firefox

REUSE status

Problem

Firefox is a great and powerful web browser by Mozilla, and Plasma is a great and powerful desktop by KDE.

The problem is that one of the most powerful features of Plasma – Activites – do not work well with Firefox.

There are several pain points in this combination out of the box, including:

  • a link opened in one Activity could open in a Firefox window in a different Activity (sometimes even starting that extra Activity, if it was stopped)
  • when resuming a stopped Activity with Firefox in it, it would sometimes spawn other Firefox windows that are not related to that Activity
  • in general Firefox windows tend to move around Activities where you do not expect them to be

This small script tries to work around those limitations.

Solution: Make Firefox aware of Activites

In short, using activityfirefox you can have a Firefox window (or several) in each Plasma Activity, and they will be bound to that Activity.

What activityfirefox does is to create a Firefox Profile for the Activity (using its unique ID) it was ran in.

Then every next time you run activityfirefox in that Plasma Activity, it will start the Firefox Profile associated with it.

Installation

Save the activityfirefox script to somewhere in your $PATH.

In my case, I saved it to ~/.local/bin/activityfirefox and have that folder in my $PATH.

E.g. in Fish shell, this is what I did:

git clone https://gitlab.com/hook/activity-aware-firefox.git
mkdir -p ~/.local/bin/
cp activity-aware-firefox/activityfirefox ~/.local/bin/
set -U fish_user_paths ~/.local/bin/ $fish_user_paths

Next, make sure your desktop knows about this "new" browser, by giving it a .desktop file. For example copy the one provided in this repository:

mkdir -p ~/.local/share/applications/
cp activity-aware-firefox/activityfirefox.desktop ~/.local/share/applications/

And finally, make sure that Plasma uses your new "Activity-aware Firefox" as the default browser:

  • open System Settings
  • either search for "browser" or navigate manually to: PersonalisationApplicationsDefault Applications
  • and there under Web Browser select the new entry called "Activity-aware Firefox"

Running

From this point onward, just use the "Activity-aware Firefox" browser as your broser of choice and be happy about it :)

Caveats

There are some caveats, of course:

The biggest annoyance is that due to the fact that Firefox kills itself if it has been sleeping for a certain period of time after receiving e.g. SIGSTOP, if you resume a stopped Activity, Firefox will start with the default profile. You need to close that window and simply start "Activity-aware Firefox" and it will come back as expected.

A limitation of this script is that add-ons, bookmarks, settings, etc. are not copied (except for chrome/) – I suggest using Firefox Sync to sync all of this between Firefox Profiles. This is is also needed if you want to move tabs between Profiles/Activities.

Syncing everything through Firefox Sync can take some time when you run the "Activity-aware Firefox" in a new Plasma Activity for the first time – depending on how much stuff you sync, of course.

Specifics for different use-cases

How to find your default Firefox Profile

Depending on your installation, your default Firefox Profile will either be in ~/.mozilla/firefox/????????.default-release/ or ~/.mozilla/firefox/????????.default/.

You can find the exact folder by going through the menu HelpMore Troubleshooting Information and in the tab that pops up search for "Profile Directory".

How to clean up Firefox Profiles not used anymore

After you stop using some Plasma Activities and as such the Firefox Profiles, you may be left with Profiles staying around. You can use firefox --ProfileManager to manage your existing Profiles, including removing them.

If I find a safe way to clean up in an automated way, I will add it.

Firefox Sync

If you want to make sure the new Firefox Profiles look similar to each other, you might want to

With Firefox Sync you can decide (per Profile/device) which of the following you want to sync:

  • bookmarks
  • history
  • open tabs – does not auto-sync tabs, but allows you to move tabs between Profiles (and devices)
  • logins and passwords – uses Firefox Lockwise
  • credit card info
  • add-ons
  • preferences – not all preferences are synced though, as some are deemed too specific to be safely synced

If you use Firefox Sync, it makes sense to rename each "device", so you know which Profile is which. A good option is to include the Activity name and the machine name.

One way of achieving something similar locally would be to carefully copy the contents of the default profile’s folder into the new profile’s folder. But that is not advised, because there are many things that are profile-specific, so if you do that, things tend to break.

Rename Firefox windows to match the Activities

If you want to more easily identify which Firefox window belongs to which Plasma Activity, you can use the Window Titler add-on to change the names of Firefox windows.

Apparently it should be possible to do this through the Desktop as well using Native Messaging WebExtension, but that is beyond my skills.

Tree Style Tab

Hiding the tab row

If you use the Tree Style Tab add-on, you probably want to hide the tab row on the top.

For your convenience, see userChrome.css in this repository and copy it to your default profile. If chrome/ folder does not exist yet in your default profile, create it.

Although the chrome/ folder is copied when you first run this script, since Firefox 57 user chrome is by default disabled. So even after everything syncs over Firefox Sync, you will need to enable user chrome yourself. You can do so, if you:

  • open about:config
  • confirm that you will be careful ;)
  • search for toolkit.legacyUserProfileCustomizations.stylesheets and enable it
  • restart Firefox, so that change applies

If you still see the top tab-bar, check which your default Profile is. This script assumes the default profile is **.default-release, but on certain installations that might be **.default instead. if that is the case, change the DEF_PROF variable definition accordingly in the script.

Sending groups of tabs to a different Activity

If you want to send whole branches of tabs to a different Firefox Profile (in our case: a Firefox window in a different Plasma Activity), you should head out to about:addonsTree Style TabPreferencesContext MenuSend Tabs to Other Devices with the context menu via Firefox Sync and follow the instructions there.

You will need to do this for every Profile that you want to tab trees to and from, as unfortunately this add-on does not see the device names of Firefox Sync.

Firefox Multi-Account Containers

If you use the Multi-Account Containers add-on, it can sync its containers settings through Firefox Sync, but you need to trigger that through the add-on itself.

Worldbrain’s Memex and other add-ons using local storage

Some more complex add-ons that make use of local storage – e.g. Worldbrain’s Memex – cannot sync through Firefox Sync. You have to take that into account.

(At least for Memex, its team is working on a way to sync between devices separately.)

How to move a vast amount of tabs

If you already have a huge amount of tabs open that you want to migrate to your new Activity-aware Firefox Profiles, I suggest you use the Bulk URL Opener add-on.

Inspiration & further reading

This is where I pulled inspiration from to create this script.

I would also like to thank the official #general:mozilla.org Mozilla Matrix channel, Ivan Čukić, Kai Uwe Broulik, and Lim Yuen Hoe for all their help.