You are not logged in.

#1 2012-03-19 09:17:55

technononsense
Member
From: Right there
Registered: 2008-07-04
Posts: 20

Support for kde activities in firefox

I've just started making use of activities in kde but prefer firefox over the kde browsers. One thing missing though is proper suppoert for firefox profiles so I've put togeter a quick bash script and a .desktop file to take care of it.

Before you use it make sure that:

1)you only have one firefox profile named "xxxxxxxx.default" in your ~/.mozilla/firefox/ folder. There's no mechanism for handling more than one yet (maybe in the future)

2) you've enabled/conigured firfox sync- tick all boxes required *except* tabs- that would defeat the purpose.

Put this script somewhere in your path (mines at /usr/bin/) and make it executable

#
# Compatability for Firefox and kde 4.x's activities.
#

ACTIVITY=$(qdbus org.kde.kactivitymanagerd /ActivityManager CurrentActivity)
FF_FOLDER=$"$HOME/.mozilla/firefox"
DEF_PROF=$"$FF_FOLDER/????????.default"
NEW_PROF=$"$FF_FOLDER/????????.$ACTIVITY"


if [ -d $FF_FOLDER/????????.$ACTIVITY ];
then
        firefox -no-remote -P $ACTIVITY

else
        firefox -createprofile $ACTIVITY
        cp -a $DEF_PROF/* $NEW_PROF/
        cd $NEW_PROF
        rm sessionstore.*
        cd ~
        firefox -no-remote -P $ACTIVITY &

fi

exit

and a .desktop to /usr/share/applications/kde/firefoxkde.desktop

[Desktop Entry]
Name=Firefox-kde
GenericName=kde Web Browser
Exec=firefoxkde %u
Icon=firefox
Terminal=false
Type=Application
MimeType=text/html;text/xml;application/xhtml+xml;application/vnd.mozilla.xul+xml;text/mml;x-scheme-handler/http$
StartupNotify=true
Categories=Network;WebBrowser;
InitialPreference=10

Feedback,comments,suggestions all welcome. This is my first ever contibution to anything though so go easy please!

Offline

#2 2012-05-31 23:45:23

mbroe
Member
Registered: 2011-05-04
Posts: 3

Re: Support for kde activities in firefox

Nice script; I really like the concept of using a profile named for the activity. But for profile administration, couldn't you just use
firefox -ProfileManager
?

Offline

#3 2012-06-01 07:15:46

technononsense
Member
From: Right there
Registered: 2008-07-04
Posts: 20

Re: Support for kde activities in firefox

You could yeah.

This script is just to automate the opening of firefox on any given activity.

For example, I use a profile named 'uni'. If I open firefox whilst in the uni activity, it opens my uni profile.

I could ammend the script to use the activity name rather than the hash but this way is more robust. If you rename an activity, the hash stays the same.

You can grab the hash of the current running activity with:

qdbus org.kde.kactivitymanagerd /ActivityManager CurrentActivity

This is just the same string shown in profile manager, and the same in your firefox folder ($HOME/mozilla/firefox/)

Any suggestions on how you'd prefer it )to work?

Offline

#4 2012-06-01 13:20:40

mbroe
Member
Registered: 2011-05-04
Posts: 3

Re: Support for kde activities in firefox

Ah, clever.  I unfortunately didn't get a chance to test it, but I was under the impression it was using the name of the activity, not the unique hash.  Great idea!

Offline

#5 2013-01-16 15:28:08

adrian15
Member
Registered: 2013-01-16
Posts: 3

Re: Support for kde activities in firefox

Thank you technononsense!

  I want to share back my own implementation found at:

http://adrian15sgd.wordpress.com/2012/1 … a-firefox/ .

Basically the improvements are:

  • Delete firefox profiles associated to no longer existant activities at desktop login

  • List of firefox profiles that haven't to be deleted

  • Adapted to iceweasel (Debian's own firefox fork)

Additionally I've set up a local firefox sync server ( http://adrian15sgd.wordpress.com/2012/1 … ync-local/ ) so that I don't have to sync to the Internet each time I open a firefox instance in a new activity. Or, I don't know... I'm offline.

Both of my posts are written in Spanish.

There are only two drawbacks:

  • I don't know how to create a new window when you're in a activity where your firefox has been already opened. It just says that firefox is already opened. I use the same icon file that runs the special firefoxkde script. (I just use. File. New Window.)

  • If you happen to move a windows between activities it doesn't get the activity changed as you would expect when you get used when you use Konqueror, because you know, Konqueror supports Kde4 activities out of the box. (I don't usually move firefox windows between activities so it doesn't bother me).

Enjoy and thank you again!

adrian15

Offline

#6 2013-01-16 21:02:50

technononsense
Member
From: Right there
Registered: 2008-07-04
Posts: 20

Re: Support for kde activities in firefox

Good to see it's some use for you.

To be honest, I never use multiple windows for the same task so I'd not noticed.

If you start firefox with the "--no-remote" option then you can't attach other windows to the same process from outside the process (hence the name I suppose). So if you start firefox with:

firefox -P $ACTIVITY

Then you can open a new window later with

firefox --new-window

The problem is that if you start without "--no-remote" then all new windows are attached to the first process started, regardless of which profile you pass in the argument. However if you do include "--no-remote" you cant pass new windows to the process. There must be a workaround though, I mean, you *can* open another window, in the same process from the GUI.
I've asked the question over at mozilla to see if there's another solution to work around it.

I like that you've added the script to clean up old profiles. It's something I meant to implement for ages but never got round to it. As it turns out I shifted from KDE to HerbstluftWM a few months ago. I've been pondering how to implement an activity based work flow into hlwm It's the only thing I miss from using a desktop environment.

Offline

#7 2013-01-17 03:20:02

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 5,662

Re: Support for kde activities in firefox

I have to say I still don't understand activities.

However, I think that automatically deleting firefox profiles could be catastrophic and I personally would not use anything which might do such a thing however convenient it might otherwise be.

Suppose a user needs to move ~/.kde4 aside to debug or solve a problem. As happens. I suspect, though I'm not sure, that will delete all the user's activities. Will all the profiles then get deleted as well? Even if that's not a problem, it seems like it might be easy to delete an activity by accident/without really thinking.

Maybe I just have a firefox-profile-dependency problem...


How To Ask Questions The Smart Way | Help Vampires

Arch Linux | x86_64 | GPT | EFI boot | grub2 | systemd | LVM2 on LUKS
Lenovo x121e | Intel(R) Core(TM) i3-2367M CPU @ 1.40GHz GenuineIntel | Intel Centrino Wireless-N 1000 | US keyboard with Euro | 320G 7200 RPM Seagate HDD

Offline

#8 2013-01-17 08:18:29

technononsense
Member
From: Right there
Registered: 2008-07-04
Posts: 20

Re: Support for kde activities in firefox

All of firefox;s profiles are stored in ~/.mozilla/firefox/ so deleting ~/.kde4 would not affect them. You'd have lost your activities names but firefox profiles can always be renamed to match without affecting their contents.

Accidentally deleting profiles wouldn't be a good thing to do. My original script is just a launcher, so all deletion was manual. Adrian's addition does delete old profiles that no longer have an activity but it also has a way of ignoring specific profiles. It would be a good idea to ignore any *.default profiles by default though. There's also the point firefox profiles can be kept in sync, as they are in the original post. Even if all profiles were deleted, there would still be a backup in the cloud.

This isn't catastrophic though, its just an easier way of configuring firefox for a specific task, and having it open said configuration when needed. It's no different to adding/removing profiles via profile manager. You said you don't understand the activity based workflow. This just automates profile managers job by passing a variable to specify which profile be added opened or deleted rather than duplicating the work by doing it in kde and then in firefox.

Offline

#9 2013-01-17 09:59:16

adrian15
Member
Registered: 2013-01-16
Posts: 3

Re: Support for kde activities in firefox

cfr wrote:

I have to say I still don't understand activities.

Well, there's too much more (like the desktop widgets) than what I'm going to explain here and there are articles that explain better than me.

Stock KDE has always let you save your applications when you close your session or shutdown the computer. The "set of applications" that were opened is called session. So... KDE when you boot again tries to open your opened applications at the same desktop where they were opened and with the same files that were open.

You can for sure exclude or force the load of some of these applications at login, but that's for another thread.

The thing is that you sometimes have a set of applications (and files opened) geared towards an specific activity. You might choose you to put them into a single desktop. That's great at the beginning but when you have too many activity-related-applications it's cumbersome. Too much applications opened at the same time. Or too many times changing the number or name of the virtual desktops.

So... If there were an specific way of saving a session of only the activity-specific-applications? So... that these applications just opened in a virtual desktop just for them?

Well... X11 Desktops were not powerful enough and Kde people invented another dimension on the work management called activities.

So basically when you stop an activity you just save the session (set of applications opened and its opened files) of that activity,not of all of your programs as before. When you start an activity (either manually or automatically because it was already opened when you closed your desktop session) all the saved session is restored.

The trick is that applications need to be activity-aware when it comes to save session, restore session and have not surprises as having all the windows of a given application in the same one activity or desktop. So... most of KDE applications are or will be activity-aware.

While the Mozilla people (or the people that make the mozilla-qt integration) decide to implement activity support for Firefox we need a workaround. And it seems this is a quite pretty one. It could be improved with hard links in order not to waste so much space with repeated profiles but I'm not quite sure it would work.

About deleting unused profiles technononsense explains my script exceptions that avoids accidental loose of information. I cannot live without deleting unused profiles because I use temporal activities a lot.

Offline

#10 2013-01-18 01:22:14

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 5,662

Re: Support for kde activities in firefox

I know mozilla's profiles live elsewhere but if you need to delete ~/.kde4 won't that delete your activities and won't that result in the associated profiles being deleted?

Note that for me deletion of my firefox profile really would be catastrophic. I have a lot of tabs, bookmarks, passwords etc. in firefox and a great deal of work would be lost, much of which I might not be able to reconstruct and some of which I might not even realise I had lost.


How To Ask Questions The Smart Way | Help Vampires

Arch Linux | x86_64 | GPT | EFI boot | grub2 | systemd | LVM2 on LUKS
Lenovo x121e | Intel(R) Core(TM) i3-2367M CPU @ 1.40GHz GenuineIntel | Intel Centrino Wireless-N 1000 | US keyboard with Euro | 320G 7200 RPM Seagate HDD

Offline

#11 2013-01-25 14:55:31

adrian15
Member
Registered: 2013-01-16
Posts: 3

Re: Support for kde activities in firefox

cfr wrote:

I know mozilla's profiles live elsewhere but if you need to delete ~/.kde4 won't that delete your activities and won't that result in the associated profiles being deleted?

You choose a profile as your default profile and check its name in the mozilla profile folder. Let's suppose its name is:

hello242ney.default

Then you edit my proposed /usr/local/bin/firefox-clean-old-activies-profiles file and you make that you have:

PRESERVED_FOLDERS="hello242ney.default"

.

The script is designed to ignore its deletion.

So if you ever delete .kde4 when at the same time the PRESERVED_FOLDERS is well defined (as indicated above with your default profile directory name) you will loose all of the other activities profiles and specifically their sessions but not this one. What about history, bookmarks and so on? You will have them at the sync server (be it local, remote or the Mozilla default). If you have setup everything right the next time you open the default Firefox profile you will have them.

Finally, if unsure, as technononsense suggests you can put:

PRESERVED_FOLDERS="*.default"

.

If you want to be sure you can also comment the rm -rf line so that it has a # symbol in front of it.

Before:

rm -rf ${dir_to_delete}

after:

#rm -rf ${dir_to_delete}

and run it from the terminal with:

/usr/local/bin/firefox-clean-old-activies-profiles

The script will inform you of the folders that are deleted and the ones that not deleted without deleting them in any case because you commented the rm -rf line!

And finally if you don't want to bother about this deletion thing don't install the deletion script. The other script should work alone too.

adrian15

Offline

Board footer

Powered by FluxBB