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
Make a note of it somewhere. You can also get a list of all activity GUIDs with
qdbus org.kde.kactivitymanagerd /ActivityManager 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:
- Remote object:
- Arguments: The GUID from the first step, e.g.
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"
GUID is the GUID of the activity.
That’s basically it, have fun!