Firefox and Plasma Activities

You may know that when you stop an Activity some opened apps can “hibernate”, they free RAM but when you restart the Activity they reappear in the same state (Dolphin at the same path, Kate and Okular with the same documents etc) and the same size and position on the screen. This generally works for KDE applications. But at the moment KDE misses a good web browser and so I use Firefox.

Mozilla’s browser has an option to automatically restore the previous session (tabs) when you start it. I use this feature a lot but sometimes I want to keep a session “saved” while I open a new one for another task (work vs study vs entertainment etc). This is why I tried to combine Firefox’s profiles (each one has its own “session”) with Plasma Activities.

I wrote a script that copies the “default” Firefox profile (with history, addons, settings, everything) into the same folder with a new name, create an entry in the app menu and link it to the current Activity. So if you set you desktop to show the files linked to current Activities (or if you set a folder view as explained here to make a by-activity app menu) you will get a different Firefox launcher for each Activity.

Just run the script and it will ask you a name to let you identify the launcher, for example if you reply “Study” the launcher will be “Firefox (Study)”.

The following image show a folder view plasmoid set to show *.desktop files linked to the current Activity:

Start the script using the right click menu on Firefox launcher

If you want a quick entry to start the script, I suggest you to edit the Firefox launcher in ~/.local/share/applications with an action as in the following image:

You have to add to firefox.desktop the follow:


[Desktop Action Activity]
Name=New profile for current Activity


Before using the script, be sure that there is firefox.desktop in ~/.local/share/applications and Firefox stores profiles in ~/.mozilla/firefox. If not, edit the script to use the right paths for your system.

Also: don’t exaggerate with Firefox profiles because each of the is approximately hundred megabytes.

I didn’t add any way to delete the profiles, just go to ~/.mozilla/firefox and manually delete them. And manually delete the entries in ~/.local/share/applications.

If you restart the script in an Activity that already has a profile linked it will be overwritten.

I hope this could help you as it does for my workflow.

Comments (Markdown supported):

  1. Very cool! It was one of my many desires to sync activities with Firefox sessions. Thank you 😉

    1. You are welcome!

  2. Sławomir Lach

    Can I run many profile at the same time? Can I launch page on current activity profile (for example switch to study, open akregator and open link in Firefox at study activity, but in situation I have Firefox opened on other activities)?

    1. Yes, you can run multiple profiles at the same time. If you open a link from another app it will be opened in Firefox running in the current Activity, also if there is another Firefox in another Activity.

      But if there is Firefox running in another Activity and none in the current one, the link will be opened in Firefox in the other Activity.

      I just discovered that restoring session doesn’t work if there is already a Firefox running. This because I used to close Firefox in an Activity before starting another one.

      If the intention is taking advantage of sessions this method works. But using a different Firefox window for each Activity is something that can be done also with a single Firefox profile. It’s a weird use case the one where the user want to restore a previous session by opening a link from another app.

      1. Sławomir Lach

        Sorry, but I have problem with this. I have disabled session restore and launch script twice time. Once I ran one of created link to application, it opens it correctly. But, I can’t start different session on different activity – only new window is opened.

        Maybe the mater are pined tabs I use?

  3. summer_parade

    sed s./home/alex.~. ff-kactivities

    check row 15 😉

    1. Thanks! Replaced /home/alex with ~.

  4. summer_parade

    Just for the record, on Plasma 5.8, where is not possible to pin apps to activities, the alternative is to make kwin window rules.

    However it is tricky with firefox profiles because kwin rules are based on window classes and not on executables, if I get it right.

    So for example, each different firefox profile will always run with the same window class:

    WM_CLASS(STRING) = “Navigator”, “Firefox”

    Therefore the executable string for each profile should include also a custom class string, e.g.:

    firefox -P profile2 --class=firefox-profile2

    to allow different kwin rules for each ff profile.

    However this seems to create issues with grouping icons in panels as the ff launcher and different ff instances are grouped separately, but I’m still investigating it.

    Also, different ff profiles in different activities in plasma 5.8 don’t manage links as you said, always the first ff instance get all the links.

    Do you know alternatives to this solution for plasma 5.8?

  5. That sounds awesome!

    How error-proof is this solution?

    Previously I tried some other similar hacks and what happened is that eventually if I had to hard-reset or something similar, Firefox would occasionally forget all the windows and groups etc. apart from one window, so when the session was restored, I’d lose dozens of tabs.

    A single-window Firefox solution I use currently is to use the addons as a quasi-Activity:
    • Simple Group Tabs to keep the running ones open grouped by topics; and
    • OneTab to store and group any tabs that I don’t currently need open.

    1. It works well for me, no unexpected behaviour. Just use profiles one by one (clone the one you are not using) and everything works.

      About Simple Group Tabs and OneTab, good to know, thanks!

  6. Pingback: Links 6/7/2017: Thousands of Microsoft Layoffs, GNU/Linux Preinstalled, Hotspot 1.0 Released | Techrights

  7. Pingback: Pytivity by Quentin Dawans: manage Plasma Activities from command line and some automation – Dissentio ergo sum

  8. Dngrsone

    I have a number of profiles set up, and I put an icon on each Activity desktop for each profile. DOn’t forget about FFs new container system–you can hide all the tabs in a container.

    1. Do you mean this I’m a huge fan of it. I would love if Firefox adds command line options to open containers, it would make me able to integrate it with Plasma Activities.

Leave a Reply