Make Linux KDE Plasma Activities Work for You

1

Overview

KDE Plasma “Activities” are a great idea. The idea is that you can collect a number of applications and files in a group, present them together, and not be distracted by a host of other objects irrelevant to that Activity.

They are a superset of “Desktops”,in that they can contain a number of Desktop configurations.

We define a number of different activities with a nickname and keyboard shortcut, create the activities, and populate each Activity with a shell script stack and control the individual application instances with the KDE Window Rules system settings.

Creating Activities

We defined the following activities:

 

Activity

Nickname

Shortcut

Computer Administration

Admin

Ctrl+Shift+a

Communications

Comms

Ctrl+Shift+c

Software Development

Devel

Ctrl+Shift+d

Engineering

Engnr

Ctrl+Shift+e

Finance

Finance

Ctrl+Shift+f

Graphics

Graphx

Ctrl+Shift+g

Holdings

Hldg

Ctrl+Shift+h

Marine

Marine

Ctrl+Shift+m

Medical

Meds

Ctrl+Shift+o

News and Weather

News

Ctrl+Shift+n

Planning

Plans

Ctrl+Shift+p

Work

Work

Ctrl+Shift+w

Default

(None)

Ctrl+Shift+t

Activities Manager

We create the activities using the KDE Activities Manager. We access it by right-clicking the desktop and choosing the Activities entry. You can also add the Activities Manager to the task bar.

Scroll to the bottom of the Activities Manager and click on + Create Activity… It brings up this screen (Plasma 5):

  • Assign an icon

  • Do not assign a shortcut in this dialog. These do not work.2

Keyboard shortcuts

Creating keyboard shortcuts is a matter of first creating the Activity then using the Desktop Bus (dbus) to find its 32-character hexadecimal Globally Unique Identifier (GUID), then assign a keyboard shortcut to the GUID.

Finding the GUID

This link was very helpful:

https://blog.hanschen.org/2011/05/20/switch-to-specific-activities-with-keyboard-shortcuts/

Current Activity GUID

This command lists out the GUIDs for the current Activity:

qdbus
org.kde.ActivityManager /ActivityManager/Activities CurrentActivity

All activities GUIDs

This command lists out the GUID for all activities:

qdbus
org.kde.ActivityManager /ActivityManager/Activities ListActivities

The list is ordered by the activities in the Activity manager at the time the command was invoked, so use the Activity Manager to step through each Activity and get its GUID with the previous command..

You then have a nice table when you’re done:


Assigning keyboard shortcut

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

1. Go to

System Settings → Shortcuts → Custom Shortcuts

2. Click on

Edit → New → Global Shortcut → D-Bus Command.

3. 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. Ctrl+Alt+w).

4. In the Action tab enter the other fields:

Remote application: org.kde.ActivityManager

Remote object: /ActivityManager/Activities

Function: SetCurrentActivity

Arguments: The GUID from the first step, e.g.:

a589200e-1983-4825-8275-50de36c223e5

5. Click on Apply

Assigning Applications

Application types

It turns out that there are (at least) four types of applications for each Activity.

  • Activity-specific applications are those that are used in only in a particular Activity. There are a host of these.

  • Multiple-Activity applications are those that are used in more than one but not all activities and need to show different content depending on the Activity.

These include:

Evolution Different views (Inbox, Calendar, Tasks) to be loaded for each Activity

LibreOffice Calc Different spreadsheets for each Activity

  • Common applications are those that are used in all activities but need to show different content depending on the Activity.

These include:

  • Chromium Different url_[Activity].txt to be loaded for each Activity

  • Geany Different Project to be loaded for each Activity

  • Konqueror Different Profile to be shown for each Activity

  • Core applications are applications that must appear in all activities with the same content when switching between activities.

These include:

Scripts

We then configure each Activity for the four types of applications. This is done with a series of scripts:

The scripts are discussed in more detail here.

The core applications are defined by the KDE Autostart that starts them when the system boots up and then the Window Rules (below) assign them to be Forced to All Activities. So we do not need any script to start these.

This successfully results in having each Activity populated with the desired Activity-specific, multi-Activity, common, and core applications and use cases.

Window Rules

We still have a problem after all that work of having application profiles appear in the wrong Activity.

The solution lies in fully understanding KDE Plasma 5 Window Rules. You can use these rules with sufficient granularity to ensure that your particular application’s use case appears where you want it to appear and nowhere else.

Accessing Window Rules

You can either right-click on a window title bar and choose

More actions → Special application settings

or use the Kicker:

System Settings → Workspace → Window Management → Window Rules

You can define a different rule for a host of different windows here.

Each rule has a host of settings and tabs, but it turns out that only a few matter in this regard.

Window matching tab

The first is the Window Matching Tab:

The Windows Matching screen has three key fields: Description, Window class, and Window title:

The first step is to assign a unique identifier in the Description field, or else you’ll drive yourself nuts with zillions of “Application settings for [application]”, which is to what it defaults.

The next step is to fill in the Window class field. If you come in from the title bar it is already filled out for you (recommended) otherwise you will have to find the right identifier.

Finally you need to decide how to modify the Window title field:

    • Core and Activity-specific applications require no further specification here since they have been fully defined for a Force assignment.

    • Common and Multi-Activity applications must use Window title: Substring Match to define a piece of the Window title that uniquely identifies the particular instance of an application that you wish to assign to a particular Activity.

Size and Position tab

The Size and Position tab has one key field: Activity.

It is modified as follows:

    • Core applications are set to Force: All Activities

    • Common, Multi-Activity, and Activity-specific applications whose Window title has been defined as above then use: Force:[Activity]

Conclusion

Activities are a powerfully useful concept for making work flow more efficient and saving time.

But there is sparse documentation on how to.

We have successfully run this gamut. We hope that this presentation will make life easier for others, and perhaps help the developers in automating this process further.

Like anything else:

“Easy when you know how.”

1C. Andrews Lavarre
Privus Technologies, LLC
EIN: 46-5240799
RI Entity ID: 875119
P.O. Box 149
Newport, RI 02840-0149
alavarre@gmail.com
(401) 339-7189
www.privustech.com

2https://bugs.kde.org/show_bug.cgi?id=342186

 

4 thoughts on “Make Linux KDE Plasma Activities Work for You”

  1. Thanks for the tips regarding setting up activities. I have been mostly trying to do it using solely window/application rules , it’s really good to have a more thorough setup, including qdbus keyboard shortcuts.

    As for the scripts, I didn’t understand exactly what do you do besides using windows rules. Could you provide more details? How do you set scripts to autostart when an activity is started?

    Finally, I have a problem when rebooting that all previously open programs appear on the current activity, no matter the previous bindings. This is where, I think, shell scripts come to the rescue. Would it be so? And then, in your kde system configurations, do you choose not to remember last session’s opened apps, or some sort of option like that?

    1. by the way, when you wrote:
      “…Core and Application-specific applications require no further specification here since they have been fully defined for a Force assignment.”

      I guess you wanted to write

      “…Core and Activity-specific applications…”

    2. Rodrigo hi, thanks for the reading and comments.

      Yes you caught the typo… 🙂 I’ve corrected it. Just proves, nothing is perfect, but better to live at the 98th percentile than the 50th… 🙂

      It’s still a learning process, so a work in progress, but we have been making considerable progress. Hope to write it all up soon, perhaps this weekend.

      Yes, the activities show up all over the place despite the windows rules. But I have discovered that if you step through the activities and then **minimize all the windows in each activity** then when you are done they have all returned their respective corrals… Thereafter they behave correctly.

      As for activities triggering scripts, that is backward: the script is written to trigger the activity by calling its GUID and then execute the activity specific actions using the activity-specific start_{activity} script before moving on to the next activity.

      I’ve posted these scripts to
      http://privustech.com/index.php/start-activities-scripts/

      Again, much progress, hope to document soon, but family and Thanksgiving come first.

      Enjoy the holiday. Cheers, Andy

Leave a Reply

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

WordPress spam blocked by CleanTalk.