how to list windows per KDE/Plasma5 Activity

Viewed 487

I am trying to write a script that launches an app if not running or activates the window if already visible in the current activity.

Using xdotool or wmctrl I am able to get the list of windows and activate them. If they are not open, then I can launch them. But the problem comes with KDE Activities. These tools list windows from all the activities even if they are not visible in current activity.

I am going through various qdbus methods but not finding anything close.

have anyone created such scripts? how one could get the windows visibility with respect to the activities?

Edits: as shown in the picture below , I was able to see the activity IDs that the window is attached to. But I am not able to find any way to get it programmatically.

enter image description here

1 Answers

An alternative aproach was given in kde forum. But it is not completely clear if it can help solve your issue.

The recommendation is as follows:

On the activity level you can make use of URI > Activity relations and query dbus for further scripting. For example:

  1. Link a directory to an activity in dolphin.
  2. Add an application "dolphin-directive" to application launcher and make it run a custom script to conditionally start dolphin instances.
  3. Set "dolphin-directive" as default filemanager

A similar workflow is possible for each filetype via File Association Settings

As far as I could figure out through experiments it is not possible to link windows to activities and query relations via ActivityManager. I guess the multiple-screen-workspace-uri-activity-window-rule architecture is supposed to setup workflows to solve the problem in a more holistic manner. But hopefully someone can give a better answer here.

I wrote a script to regex inspect the whole session bus tree for related and usefull methods. You can simply use it by ./query-dbus.py --pattern "^.*activit.*$". So the answer is work in progress.

EDIT: some services do have the method isMonitorActivity, isOnActivity

"org.kde.konsole": {
    "/Sessions/1": {
      "org.kde.konsole.Session": {
          "method": [
            "setMonitorActivity",
            "isMonitorActivity"
          ]
      }
    }
}
    

"org.kde.kate": {
    "/MainApplication": {
      "org.kde.Kate.Application": {
          "method": [
            "isOnActivity"
          ]
      }
    }
  }
}

Did you already file a feature request?

Related