Is there a way to track the amount of time spent in a KDE activity?

Title. Is there an inbuilt way or an external application that can track how much time I am spending on an activity? I usually do different tasks such as gaming or work in separate activities and want to know whether it is possible to know how much time I am spending towards my work.

I’m not familiar with a Plasma capability for that, but you can adapt my activity monitor script to do this measurement.

But you’d also need to measure idle time and reduce activity time by the idle time spent on that activity.

Something similar would be KTimeTracker (, but I think it is unmaintained atm - which is quite unfortunate, because many people I know also need exactly such an application…

IIRC KTimeTracker requires manual operation, so the way to use it (or any time tracker - there are thousands) is to hit a shortcut, or run a command, every time you switch activity.

Can we set KTimeTracker so that it automatically starts or pause its timers everytime an activity is switched? If so, that is what I need!

There may be some sort of solution that can be put together, but it would require running scripts and the first thing I noticed is that KTimeTracker doesn’t seem to have command-line actions to start/pause/stop tracking.

From a quick search online, it looks like there are some CLI programs like Timewarrior or timetrace, or there’s a GTK/GNOME program called Hamster which all seem to have some degree of control via command-line and could potentially work with being controlled by scripts.

With a time tracking app selected, one solution would be to use Pytivity, which may be a quicker solution than the below, as it allows you to configure commands to run when activity states change.

Another solution would be to manually setup scripts (.desktop files will also work apparently, but I’ll keep referring to scripts) that kactivitymanagerd will run. To do this you need to place the scripts under ~/.local/share/kactivitymanagerd/activities/{activity_uuid}/{state}/, where {activity_uuid} is the UUID for the activity and {state} is one of: activated , deactivated , started or stopped. You would probably need to create the activities folder under ~/.local/share/kactivitymanagerd/.

To find the UUID’s, you can get them via dbus with:

qdbus --literal org.kde.ActivityManager /ActivityManager/Activities org.kde.ActivityManager.Activities.ListActivitiesWithInformation

The output should look something like [Argument: a(ssssi) {[Argument: (ssssi) "2b51e992-14be-4e3b-a090-89ffe2d0d5a0", "Default", "", "", 2], [Argument: (ssssi) "fb836882-de8f-44ab-a5ea-807442eb24a0", "Test", "", "activities", 2]}] which has two activities, one named Default and one named Test.

For the above example output, you’d create folders for each UUID, so for the Default activity, you’d have the folder ~/.local/share/kactivitymanagerd/activities/2b51e992-14be-4e3b-a090-89ffe2d0d5a0/. Under each UUID folder, you can then create the relevant state, so if you want to run something when you switch to an activity you would create a folder called activated and then for when you switch away from that workspace you’d want a folder called deactivated.

If you put scripts (that are executable of course) under the respective directories, they should run when you switch to/away from them. If you can find something that you can run a command to start/pause/stop tracking the time, you could use that.


I wasn’t aware of kactivitymanagered activity hooks - this is great to know. Thank you!

A lesser known functionality of KTimeTracker is that on X11 it lets you track time per virtual desktop. It may come close to what you want.

Implementing CLI support to start/stop tasks shouldn’t be too difficult, and at some point I’d like to make desktop tracking work on Wayland, but Activities support would require a developer with experience in that area.