Switching to specific KDE activites using shortcut keys

Today I’ve been playing around with an incredibly powerful feature of KDE – activities. This basically means you can switch between entire sets of applications and virtual desktops very easily. As a consultant I usually have several different clients that I work for at the same time plus a set of programs I use personally. KDE Activities allows you to separate these and switch between them very easily. The default keypress to circle around the different activities is meta-tab but I wanted to be able to switch directly to a specific one, however this doesn’t have any specific support in KDE. Fortunately with Linux and KDE being so flexible I found a solution to this from this thread from 2011. As I was implementing it I noticed a number of changes that have been made so here is an updated version of the instructions:

Firstly, get a list of activity ID’s and their human-readable names; from the console:

$ for i in $(qdbus org.kde.kactivitymanagerd /ActivityManager/Activities ListActivities); do echo -n "$i : "; qdbus org.kde.kactivitymanagerd /ActivityManager/Activities ActivityName $i; done
872ecadb-1388-41fe-89c5-4475c7fd137f : AAA
05104b7f-5df9-4ba2-80bf-0b3eca8a501d : BBB
a20e63e3-6ac6-4e0c-9f0f-2eebb3dfcc8b : CCC

Then open up the “Custom Shortcuts” program and create a new shortcut using “Edit -> New -> Global Shortcut -> D-Bus Command”. Fill out the D-Bus settings as follows:

Remote application: org.kde.kactivitymanagerd
Remote object: /ActivityManager/Activities
Function: SetCurrentActivity
Arguments: 872ecadb-1388-41fe-89c5-4475c7fd137f

And you’re done!

Leave a Reply

Your email address will not be published. Required fields are marked *