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:
- Remote object:
- Arguments: The GUID from the first step, e.g.
- Remote application:
- 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"
GUID is the GUID of the activity.
That’s basically it, have fun!
May 20, 2011 at 18:16
[…] Switch to specific activities with keyboard shortcuts […]
May 20, 2011 at 20:07
Hey, I can’t believe how easy is this! Yes, it indeed is! Hahaaha!!! FUCK YOURSELF
May 21, 2011 at 12:13
u sir just made my day – thx so much 🙂
Here is my current setup using activities and now .. Shortcuts!!
Another idea I had is the ability to drag&drop windows onto an activity to change it’s associated activity, or ctrl+drop to add to an additional activity (mouse centric). Alternatively a dropdown list with checkboxes in the wm’s title bar similar to the ‘Select Category’ in Kmail’s ToDo List would allow to assign several activities at once to an application. The current rightclick -> select Activities -> repeat for each activity, procedure seems quite tedious.
When I changed my desktop layout to include activities into my workflow I wished I had the ability to move the activity panel to the left with vertical text – similar to the Kate side panel and autohide it to gain back some screen estate. Kinda got used to the current setup now but still, swapping the two would allow me in this configuration to use the standard windows titles in the task manager, not only icons.
May 22, 2011 at 18:22
[…] /ActivityManager SetCurrentActivity "GUID"然后按键盘玩吧，骚年。via hanschen.WPSNS_main […]
May 22, 2011 at 21:23
You just gave me what I needed. Kudos to you!
May 23, 2011 at 0:24
@yadigaga and @Erbureth:
Glad to hear that you found it useful!
Those are pretty cool ideas, have you posted them somewhere where the developers will see them? Here they’ll most likely fall on deaf ears since I don’t have anything to do with Plasma development.
I’m pretty sure that the UI for activities will improve in the future, hope it’s sooner rather than later. 🙂
July 6, 2011 at 11:04
Brilliant. Simplicity itself. KDE 4.6 is finally doing what I want. Thanks for enlightening us all.
July 6, 2011 at 18:58
[…] Activites quickly when I have my fingers on the keyboard. I stumbled across a dbus method to assign shortcuts to a specific activity . It actually works well but my problem is that I have way to many activities than I’m […]
July 6, 2011 at 19:07
Your post inspired me playing around with dbus and find an easier way to automatically assign shortcuts to your activities. Here is what I came up with:
What do you think?
July 7, 2011 at 12:00
Nice to hear that, thank you for your comment.
Wow, that’s very cool, thanks for sharing. I would suggest you to post it to e.g. KDE-apps.org as well as the Tutorials & Tips subforum to give it more exposure. A tip if you post it to e.g. KDE-apps is that you can export the switchActivity shortcut group – by doing so other people can simply import your exported file and don’t have to create all shortcuts manually. (Maybe you can even create an install script to do all that automatically?)
October 15, 2011 at 21:15
Thank you so much for this. Now I don’t have to fight my wife over the computer!
January 26, 2012 at 14:25
I also like this Activity Manager Wheeled widget, I think it should be implemented upstream in some way:
It enable’s you to switch between activities by scrolling you mouse over the activity widget.
August 17, 2013 at 9:12
I just wanted to know that this is DEPRECATED now. In global shortcuts, select KDE Activity Manager and it will provide the relevant shortcuts.
Just to add as this page still comes up in Google Search and the other information is not as available (you need to stumble over it yourself).
August 18, 2013 at 22:12
Thanks for the reminder, I’ve added an update at the top of the post.
October 7, 2014 at 8:27
.. and in 2014, I cannot find the KDE component “KDE Activity Manager”, using KDE 4.14.1. So I used your method, but I replaced qdbus org.kde.kactivitymanagerd /ActivityManager ListActivities with qdbus org.kde.ActivityManager /ActivityManager/Activities ListActivities
February 8, 2015 at 11:58
A very late reply (my apologies), but I still have “KDE Activity Manager” in 4.14.3.
I will update the post with the new command.
August 15, 2017 at 20:51
[…] https://blog.hanschen.org/2011/05/20/switch-to-specific-activities-with-keyboard-shortcuts/ […]
March 16, 2020 at 13:01
This make my day, in Kubuntu 19.04 I have a supposed way to do this via System Settings → Shortcuts and Gestures → Global Keyboard Shortcuts → Plasma, it’s more user-friendly but I can’t get it to work. Your method works like a charm.