7 ways to switch activities

One common complaint about activities in KDE Plasma Workspaces is that it’s hard to switch between them. With virtual desktops you have many alternatives – you can use the Pager widget, desktop effects, keyboard shortcuts, switch desktop on screen edges etc. But what about activities? I counted the methods that I know and ended up with 7 different ways to switch activities (depending on how you count), all of which I’ll share in this post. Who knows, maybe you’ll find a new favorite?

Continuing with activities after a hiatus, this time how to switch between them

Note that I’m using Plasma Desktop 4.6.x – some of things described might be different in earlier versions (for example different locations in System Settings), and some might not work at all.

Standard ways

Let’s start by reviewing some standard ways to change activities, i.e., ways that are available from a fresh setup. In the next section, “Additional ways”, the methods will require some tweaking, such as changing settings or installing additional programs. I won’t cover the case when you have “Different widgets for each desktop” enabled.

Mouse

By default there are two easy ways to access the activity manager by using your mouse:

  • Click on the desktop Tool Box(usually in the top-right corner) and select Activities
  • Right click on the desktop and select Activities…

From the activity manager, click on the activity you want to switch to. You can then close the manager by clicking on the close button, pressing Esc or by moving focus to a window (for example by clicking on the window).

Activity manager

The disadvantage of these methods is that you need to have access to the desktop in order to use them.

Keyboard

Personally I prefer to use the keyboard as much as possible. If you right click on the desktop you’ll see that the default keyboard shortcut to open the activity manager is

  • Alt+D, Alt+A

It requires that the desktop has focus, which you can give it by clicking on a part of the desktop or by switching to an empty virtual desktop. This has the same problem as the mouse methods above. There is a solution though, called global shortcuts which work regardless of the application in focus (as long as it doesn’t steal the keyboard input). The default global shortcut for the activity manager is

  • Meta+Q

Meta is usually the “Windows” key on standard keyboards. You can reassign the shortcut by clicking on the desktop Tool Box, select Shortcut Settings and click on the shortcut under “Global” on the “Activities…” row.

Finally there are two global keyboard settings to switch to the previous and next activity:

  • Meta+Tab – Next Activity
  • Meta+Shift+Tab – Previous Activity

They can be reassigned in System Settings → Common Appearance and Behavior → Shortcuts and Gestures → Global Keyboard Shortcuts → KDE component: Plasma Desktop Shell.

Additional ways

If you aren’t satisfied with the default ways to switch activities, here are suggestions for other methods you can use.

Mouse actions

If you like to use the mouse but find it troublesome to switch via the activity manager, there are faster ways. Plasma Workspaces allow you to define the actions different mouse buttons trigger on the desktop. For example, you can configure the left mouse button to pop up a context menu with your activities.

Context menu to switch between activities

Click on the desktop Tool Box and select Desktop Settings. Choose Mouse Actions in the left sidebar. You can either change one of the existing mouse actions, or you can add a new action. For example, try to click on Add Action…, click on the button again with your left mouse button and select Switch Activity in the drop-down list. Now you can switch activities by left clicking on the desktop and choosing the activity you want to switch to in the menu.

If you use the Switch Activity action with a scroll button it will switch to the previous/next activity instead of popping up a menu. By default vertical scroll is assigned to Switch Desktop, try to change it to Switch Activity and scroll up/down with the mouse pointer over the desktop to switch to the previous/next activity

These are just examples, of course you can use whichever mouse buttons you prefer. If you redefine the action of the right mouse button and can’t access the desktop right-click menu anymore, you can use the desktop Tool Box to open Desktop Settings again.

The problem with these methods is the same as before – you need access to the desktop to use them (note that they also work on the Dashboard). Unfortunately Plasma Workspaces don’t support global mouse shortcuts yet, but I’ll show you how to use another tool to achieve this under “Mouse shortcuts”. Before that, however, I’ll introduce another way to use the mouse – mouse gestures.

Mouse gestures

Mouse gestures allow you to trigger different actions by holding down a mouse button and making a gesture with the mouse. For example, moving the mouse in a straight line to the right while holding down the middle button could mean “Next activity”.

Before we can add new mouse gestures we need a command to switch activities and to show the activity manager. I couldn’t find any specific D-Bus calls to achieve this, but all shortcuts in KDE Software can be called using D-Bus. (There’s a “Send Keyboard Input” option in the System Settings module , but I can’t get it to invoke keyboard shortcuts.)

Go to System Settings → Common Appearance and Behavior → Shortcuts and Gestures → Custom Shortcuts. Click on Settings and make sure that “Start the Input Actions daemon on login” and “Gestures” are checked. “Mouse button” is the mouse button you hold down to activate a gesture. Personally I like to set it to 2, which in most cases is the middle mouse button.

To create a new gesture, click on Edit → New → Mouse Gesture Action → Command/URL. Click on the Trigger tab → Edit and draw the gesture in the new window while holding down the left mouse button.

Drawing a new mouse gesture

In the Action tab, you can use one of the following commands:

  • qdbus org.kde.kglobalaccel /component/plasma_desktop invokeShortcut "manage activities" #open the activity manager
  • qdbus org.kde.kglobalaccel /component/plasma_desktop invokeShortcut "Next Activity" #switch to next activity
  • qdbus org.kde.kglobalaccel /component/plasma_desktop invokeShortcut "Previous Activity" #switch to previous activity

After pressing Apply you can test your new mouse gestures. If they don’t work, make sure that the commands work, that the group and action are enabled (checkbox to the right), that gestures are enabled in the settings and that you hold down the correct mouse button.

Mouse shortcuts

As said Plasma Workspaces don’t support global mouse shortcuts yet, which is unfortunate given that many mouse models nowadays have extra buttons. However, it’s possible to set up mouse shortcuts using an application called xbindkeys. A more detailed post about mouse shortcuts can be found here.

So first of all, install xbindkeys. Open ~/.xbindkeysrc in a text editor. Here’s an example of a .xbindkeysrc to bind one mouse button, usually for the action “Back”, to open the activity manager, and vertical scroll to switch to the next/previous activity. The button numbering can vary so you might need to change the numbers (b:8 etc.) to work with your mouse.

# Activity manager
"qdbus org.kde.kglobalaccel /component/plasma_desktop invokeShortcut "manage activities""
b:8

# Next activity
"qdbus org.kde.kglobalaccel /component/plasma_desktop invokeShortcut "Next Activity""
b:7

# Previous activity
"qdbus org.kde.kglobalaccel /component/plasma_desktop invokeShortcut "Previous Activity""
b:6

You can also use other buttons if you want – the xev command is useful for finding the button number.

Finding the mouse button with xev

When you’re satisfied with your configuration your need to start xbindkeys by running xbindkeys in a terminal (or Alt+F2). If xbindkeys already is running, you can use the following command to restart it: killall xbindkeys && xbindkeys

If you find that you need to start xbindkeys every time you login, add it to autostart in System Settings → System Administration → Startup and Shutdown → Autostart → Add Program… → xbindkeys → OK.

Icon

Yet another way to switch activities with your mouse is to put an icon on your desktop and/or panel.

An icon to show/hide the activity manager

Below you’ll find a .desktop file that opens the activity manager when clicked. Copy and paste the text in a text editor, save the file somewhere as activitymanager.desktop and you’ll have your own activity manager icon.

[Desktop Entry]
Comment=Shows the activity manager
Exec=qdbus org.kde.kglobalaccel /component/plasma_desktop invokeShortcut "manage activities"\n
GenericName=Activity Manager
Icon=preferences-activities
Name=Activity Manager
StartupNotify=false
Type=Application
X-DBUS-StartupType=none
X-KDE-SubstituteUID=false

The first time you click on the icon it will show a warning asking if you want to start the program. Make sure the command looks right, click on Continue, and the activity manager should show up.

You can easily adapt this desktop file to make icons for previous/next activity. The commands (Exec=) you need are listed at the end of the “Mouse gestures” section.

To add the icons to your desktop or panel, unlock your widgets and simply drag and drop them. See Plasma HowTo for more information.

Widgets

Finally, there are a few widgets you can use to switch activities. Activity bar is shipped with the default widgets and is exactly what it sounds like – a bar that shows your activities. A lot of people like to put it in a panel that is set to autohide, so that it stays out of the way most of the time.

Activity bar in a vertical and horizontal panel

While Activity bar provides a fast and easy way to switch between activities, it has some limitations. For example you can’t stop activities from it nor start already paused activities.

There’s a third-party widget called Activity Manager Plasmoid that acts as an alternative activity manager. It currently lacks some features compared to the original manager, such as the ability to create a new activity from a template, but for the purpose of switching between activities it does the job well. Activity Manager Plasmoid can be put on the desktop and panel as well as in the system tray.

Activity Manager Plasmoid in the system tray

These widgets are usually added to a panel to make them accessible all the time, independent of your current activity. (Your desktop changes depending on your activity.) Another solution could be to set the Dashboard to show an independent widget set instead of the current desktop and then use the Dashboard as an activity switcher. This option is found in System Settings → Workspace Appearance and Behavior → Workspace Behavior → Workspace → Dashboard: Show an Independent Widget set. Apply the setting, invoke the Dashboard (Ctrl+F12 by default) and add the widget(s) of your choice to it.

The future

There are exciting times ahead for fans of activities. In 4.7 there will be a KRunner plugin for activities, and someone mentioned a new UI for managing activities, but I don’t know what the current plans are.

This is what I would like to see in the future regarding switching activities (in no particular order):

  • Make it easier to use D-Bus to switch activity. I couldn’t find a way to switch to the previous/next activity or to bring up the activity manager using D-Bus (update: now I know a workaround way, thanks to a comment below), and when I asked on IRC, I was told that this was already in the plans.
  •  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. I found a way to do it with D-Bus, but a GUI option would be nice.
  • A more streamlined UI for switching activities would be nice. I love how smooth the desktop effects feel, even on this ancient computer – maybe a desktop effect for switching activities?
    One thing I dislike about the current manager is that it gives the impression that you need two clicks to switch activity, one to switch and another one to close the activity manager. If you open the activity manager from the Toolbar → Activities…, it sums up to four click just to switch activity! That’s at least two clicks too much, in my opinion.
  • Give activities a more central place in the workspace (like in Plasma Active). Perhaps adding an icon/widget to the default panel to show the activity manager.

Note that this is just my personal wishlist and should not be confused with the actual plans. In any case, I’m looking forward to seeing what the future brings.


Update May 15, 2011: Replaced xte commands with D-Bus calls thanks to ArnAud‘s suggestion. If the D-Bus commands for some reason don’t work for you (those starting with qdbus), you can install xte, which is usually part of a package called xautomation, and use the following commands instead:

  • xte 'keydown Super_L' 'key Q' 'keyup Super_L' #open the activity manager
  • xte 'keydown Super_L' 'key Tab' 'keyup Super_L' #switch to next activity
  • xte 'keydown Super_L' 'keydown Shift_L' 'key Tab' 'keyup Shift_L' 'keyup Super_L' #switch to previous activity

This assumes that you haven’t changed the default global shortcuts, otherwise you have to modify the commands.

Update May 16, 2011: Added a mention of KDE Plasma Workspaces in the beginning and a note about which version this post describes.

Update May 20, 2011: Added a link to the new post about switching to specific activities with keyboard shortcuts.

37 Responses to “7 ways to switch activities”

  1. ArnAud Says:

    I had the same problem a couple days ago, not finding any D-Bus call for the action I wanted to make a mouse gesture of.

    But I found that everything that has a shortcut in KDE can be called using D-Bus via org.kde.kglobalaccel !

    For exemple the activities you want to trigger:
    org.kde.kglobalaccel /component/plasma_desktop invokeShortcut "manage activities", "Previous Activity" or "Next Activity"

    Just use the org.kde.kglobalaccel /component/plasma_desktop shortCutNames to get the name of the shortcut you want to use.

  2. Hans Says:

    @ArnAud:
    That’s a cool trick, thanks for sharing! I’ll update the post and replace all xte commands with D-Bus calls.

    EDIT: WordPress converted your ” signs, so I put code tags around your commands to make it possible to copy and paste.

  3. rubentje1991 Says:

    Thank you very much for this article….
    Just the information I needed to start using activities!
    (I like them, but didn’t take the time to research the possibilities completely – now I will 🙂 )

    Very practical information in this article (and it’s clearly explained)….

  4. Hans Says:

    @rubentje1991:
    Thanks for your kind words, hope you’ll have fun with activities!

    I have now updated the post so that it’s not necessary to use xte anymore.

  5. Luca Beltrame Says:

    Bear in mind that IIRC the D-Bus API for activities is experimental and likely to change, so the commands may break in the future.

  6. Lukas Says:

    Great post 🙂

    Previously switching activities was too painful (at least for me) to even start using them 😦

    But the Meta + tab – genius is in simplicity 😀 I don’t know whose idea it was, but it just perfect 🙂

    If similar effects could be added like in Alt+Tab window switching…

  7. Hans Says:

    @Luca Beltrame:
    The commands in this post are using org.kde.kglobalaccel though, so unless the shortcut names change, they should work in future versions.

  8. Hans Says:

    @Lukas:
    Thanks. Personally I’m a fan of Activity bar in an autohidden panel since I find it slow to cycle through activities with Meta+Tab. An activity switcher list, similar to the Alt+Tab list, would indeed be very useful.

  9. The User Says:

    Umm, with virtual desktops I simply have ctrl+f1…f6, that is much faster than activity-switching using meta-tab, I tried activities for few weeks (will probably use them again, but have to reconfigure it here), and it was annoying without those plain shortcuts. I mean, when I say “I wanna do webbrowsing” I can press ctrl+f5 and I am on my webbrowsing-desktop, ctrl+f4 for chatting. That is in my experience much more efficient than these 7 ways.

  10. Strife Says:

    Thanks for sharing this, I’ve been using an auto-hiding activity bar so far but even that is slower than it need to be, hence the meta-tab tip is highly appreciated.

  11. Hans Says:

    @The User:
    Yeah, that’s why I have “The possibility to set a keyboard shortcut for each activity” on my wishlist. 😛

    @Strife:
    Thanks for commenting. I was surprised when I saw how many people didn’t know about the Meta+Tab shortcut, and that’s one of the reasons why I decided to write this post.

  12. atomopawn Says:

    Actually, my problem isn’t figuring out how to switch between activities. It’s figuring out something useful to DO with them. I would love to see a blog post or two about how you (or others) use activities to improve your workflow. It’s clear to me that an awful lot of development work has gone into these, so it would be really nice to see a few use-cases for them.

  13. Lionel Chauvin Says:

    I propose two improvements for the activity system:
    – an activity should be stopped when it is not used after some amount of time.
    – when the user starts an application that is already associated to another activity, a popup asks if he wants switch to this activity.

  14. lefty.crupps Says:

    It was quite ways into the article before this mentioned that the Activities discussion related to KDE (really, only when telling us to go to System Settings), and I don’t see anywhere that it discusses which version(s) of KDE this works with. I’m not getting it going with my Debian Squeeze 4.4.5 setup so I am guessing its at least 4.5 ? Maybe 4.6 ?

  15. Hans Says:

    @atomopawn:
    See my earlier posts How do you use activities? and Activities – A change in workflow?. The first one describes how I use activities, but it’s a bit out-of-date. In the second post I write about how I want to use activities and how I hope it’ll change my workflow.

    @Lionel Chauvin:
    That’s nice suggestion, but like very much else, it’ll not get noticed by the relevant developers. You can try to post your ideas to KDE Brainstorm and see what kind of responses you get (assuming they haven’t been posted already).

    @lefty.crupps:
    Good points. I’m used to thinking that it’s mostly Planet KDE readers who will see my post, but that’s of course not correct. I’ve updated the post with a mention of KDE Plasma Workspaces in the introduction and a note about which version I use.

    What doesn’t work for you? 4.4.x still uses the old zooming interface if I recall correctly, so everything involving the activity manager probably won’t work.

  16. kilolima Says:

    Is it possible to switch to designated activities with “meta-1” “meta-2” etc, like for virtual desktops with “alt-1, alt-2” etc?

    Because until then, this activities paradigm is not going to be that useful if you have more than 2 or three of them at once.

  17. Hans Says:

    @kilolima:
    I don’t know any easy way to achieve this (although it’s probably possible with some D-Bus magic), that’s also why it’s on my wishlist in the last section “The future”.

  18. kilolima Says:

    Hans, thanks for the reply, sorry missed your point earlier.

    I haven’t used KDE since the end of 3.5… but it looks like 4.x is about to achieve or even exceed usability parity?

    I do really like the snow desktp effect, though. Maybe that is worth the 5 year wait?

  19. Hans Says:

    @kilolima:
    Hehe no problem, funny that you picked the same shortcuts as me (I guess it’s pretty natural given the Alt+Tab vs Meta+Tab shortcut).

    If you haven’t tried 4.x in a while I definitely recommend to give it a spin.

  20. Malte Says:

    Switching to a specific activity can be easily achieved via DBus. org.kde.kactivitymanagerd is your friend. You just need to get at the activity’s rather unwieldy id (a GUID) to switch to it.

  21. Hans Says:

    @Malte:
    Yes I’ve looked it through with qdbusviewer and found it rather confusing, but I think I figured it out now. Will write a separate blog post about it.

  22. Rodrigo Rosenfeld Rosas Says:

    The main problem for me is that I couldn’t find a shortcut for moving a window to another activity. I need to use Alt+F3 twice (one for enabling in the other activity and another one for disabling it in the current activity) 😦

  23. Lanciatori: Kwin e Attività a portata di click : it-blog Says:

    […] è creabile senza intoppi, mentre per approfondimenti sulla gestione delle attività vi rimando a questo articolo, che trovo davvero ben fatto e da cui ho preso […]

  24. Mr M.S. Makhathini Says:

    the presentation is both versetile and convenient

  25. thinkMoult - Showing your activity: a plasma widget hack Says:

    […] first is how to switch from one activity to another. Apparently there are at least 7 ways to switch activities already, but all of them fail to simultaneously satisfy two criteria: 1) Being accessible via a keyboard […]

  26. Christaj Says:

    One way I would love to be able to switch my activities would be to have an activity grid, like the desktop grid for workspaces. It would show just screenshots of all activities and their associated applications in “Present Windows” style. Screenshots because if I have one activity running only and the others stopped, then I would want to see all open apps on the stopped ones. Plus with an activities grid (invoked by a shortcut), I can easily start an activity by clicking on one of the screenshots, and even grab applications and move them between activities, as is done with a workspace grid. The screenshots representing the activities would then become a live activity once it is clicked. This activity grid would also be able to create, rename, delete and stop specific activities. What I like about activities vs workspaces is that you can shut them down to conserve resources. You can’t do that with workspaces…

  27. Hans Says:

    @Christaj:

    It’s not exactly the same, but you may want to try the WorkFlow plasmoid.

  28. David Sugar Says:

    Indeed, having an activities “overview” like grid would be very nice, particularly if it can also be activated by a hot corner. Simply being able to manually control the sort order of activities even in the default activity manager would seem a major advance. I have tried all the methods noted here over time, and the only one that felt effective and natural currently available was that third party activity manager plasmoid. Easy to switch, and it at least uses names as the sort order of activities. My concern with it is simply that it does not seem to be actively maintained in several years, and likely will one day break/stop working, though so far it’s functional up to kde 4.11.

  29. Jason H. Fuller Says:

    It would be sweet to couple changing activities with launching specific apps. Thus, I’m wondering what I’d need to type at a command line to switch to Activity ‘X’?

  30. Jason H. Fuller Says:

    to be specific, qdbus commands only return: qdbus: could not find a Qt installation of ”

  31. Hans Says:

    @Jason H. Fuller:

    Maybe you need to install qt4-default or something like that?

  32. pipis Says:

    Hey, I had configured “Mouse gestures” properly, but after installing Kubuntu 14.04 they do not work,… For example, when I draw the gesture on desktop it just copies/pastes the command ‘qdbus org.kde.kglobalaccel /component/plasma_desktop invokeShortcut “Next Activity”‘ instead of going to the next activities as it did previously. Why? Any ideas? (Qt: 4.8.6, KDE Development Platform: 4.13.0)

  33. pipis Says:

    Ignore or delete my previous comment… It is ok now. Thanks.

  34. Hans Says:

    Nice to hear that you were able to solve the problem!

  35. Sergiu Says:

    The plasma_desktop path has been renamed to plasmashell in KDE Plasma 5, so the command to invoke the Activity Manager becomes:
    $ qdbus org.kde.kglobalaccel /component/plasmashell invokeShortcut “manage activities”

    To view all available plasmashell actions, run this:
    $ qdbus –literal org.kde.kglobalaccel /component/plasmashell allShortcutInfos | sed ‘s/\([{ ]\[Argument: (\)/\n\1/g’


Leave a comment