May 20, 2011 — Hans

Update February, 2015: Updated commands for newer versions.

Update August 17, 2013: In newer versions it’s possible to set the keyboard shortcut directly in System Settings → Shortcuts and Gestures → Global Keyboard Shortcuts → KDE component: KDE Activity Manager.

In my last post about switching between activities in KDE Plasma Workspaces I had the following on my wishlist:

The possibility to set a keyboard shortcut for each activity, for example Meta+F1 for the first activity, Meta+F2 for the second one etc.

This is actually already possible in 4.6, although it isn’t very straightforward for those of us who aren’t D-Bus wizards. However, since I know that there are other people who want this, I’ll share what I figured out today. After reading this post you’ll be able to set keyboard shortcuts (such as Meta+F1, Meta+F2 etc.) to switch to specific activities.

1. Find the activity id

Each activity has a globally unique identifier (GUID) which is a 32-character hexadecimal string. To get the GUID of the current activity, run the following command:

qdbus org.kde.kactivitymanagerd /ActivityManager CurrentActivity

or in newer versions:

qdbus org.kde.ActivityManager /ActivityManager/Activities CurrentActivity

Make a note of it somewhere. You can also get a list of all activity GUIDs with

qdbus org.kde.kactivitymanagerd /ActivityManager ListActivities

or in newer versions:

qdbus org.kde.ActivityManager /ActivityManager/Activities ListActivities

The list is ordered in the same way as the activities in the activity manager.

2. Create keyboard shortcuts

Now you have everything you need to create a keyboard shortcut for an activity.

Go to System Settings → Common Appearance and Behavior → Shortcuts and Gestures → Custom Shortcuts. Click on Edit → New → Global Shortcut → D-Bus Command. Enter a name for the shortcut. In the Trigger tab, click on the button that says None and press the shortcut you want to use (e.g. Meta+F1). Click on the Action tab and enter the following: Remote application: org.kde.kactivitymanagerd (newer versions: org.kde.ActivityManager )

(newer versions: ) Remote object: /ActivityManager (newer versions: /ActivityManager/Activities )

(newer versions: ) Function: SetCurrentActivity



Arguments: The GUID from the first step, e.g. a589200e-1983-4825-8275-50de36c223e5 Click on Apply.

Rinse and repeat. If you want the corresponding D-Bus command, for example to use it with another application, it is

qdbus org.kde.kactivitymanagerd /ActivityManager SetCurrentActivity "GUID"

or in newer versions:

qdbus org.kde.ActivityManager /ActivityManager/Activities SetCurrentActivity "GUID"

where GUID is the GUID of the activity.

That’s basically it, have fun!