Add shortcuts to KWin + scripting API support

I want to add support for working with this method here:

As well as setOnActivity so I can improve my workflow. So far I’ve looked at shortcuts, checked what’s available on the scripting API and browsed the DBus in attempts to add a shortcut to this method.

For now I’m probably going to add a custom shortcut through a forked Task Manager but I’d be up to doing the grunt work of adding support for this so other people can use it.

All I would need is somebody to point me to the right files.

  • Where Scripting API objects are created (such as the Client/Window or Workspace ones)
  • Where KWin shortcuts are registered.

This method is not exposed in the scripting API directly, but you can use the abstract client’s activities property to check which activities a window is on and assign the list of no or all available activities, which in turn you get from the activities property of the workspace object edit: the empty list to set it on all activities. Then use the registerShortcut to assign it a shortcut. See KWin Scripting API | Developer.

1 Like

Something like this (haven’t tested):

registerShortcut("Set active window on all activities",
                 "Set active window on all activities",
                 () => {
                     workspace.activeClient.activities = [];
1 Like

@nclarius Thanks so much for this! This was my last gripe with my activities setup. I accidentally read the KWin::TopLevel instead of KWin::AbstractClient and just assumed it was a Read-only. Thanks for the reply!

P.S. Here’s the full script to reproduce the behavior in case somebody stumbles upon it in the future.

function setOnAllActivities() {
    if (workspace.activeClient.activities.length) {
        workspace.activeClient.activities = []
    } else {
        workspace.activeClient.activities = [workspace.currentActivity]


registerShortcut("SetOnAllActivties", "SetOnAllActivities", "Meta+M", setOnAllActivities);
1 Like