Registered Member
|
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? |
Registered Member
|
Hi njnr!
Very good question! I cant believe it is not answered yet! I was thinking about the issue since early KDE4. As far as I understand the concept activities are linked to URIs. With QDebusViewer I queried some windows. They have resourceName and resourceClass property. But these properties are the window name and class, like "falkon [profilename]" is a resourceClass. So my idea was to query Activitymanager for linked window resources. But the method expects an URI I guess so it doesnt work yet. An alternative aproach is to follow the concept and work with workspaces and window rules to categorize simultanously running instances of applications like dolphin, falkon, kmail and konsole or your own app. Some apps have an option to force a new instance. Apps like Falkon have specific window classes for each profile it starts up with. So its possible to control the window behavior of each falkon instance by profile name. On the activity level you can make use of URI > Activity relations and query dbus for scripting further. 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 Please tell me if you already filed a feature request at bugs.kde.org regarding a kwin dbus method like "getWindowActivity" Cheers domson
The ships hung in the sky in much the same way that bricks don't. — Douglas Adams
|
Registered Member
|
Hi domson,
I haven't found any ways so far. ``` org.kde.ActivityManage /ActivityManager/Resources/Linking ``` seems to have some event listeners that one can listen to get notified if a resource(window in this case) is linked to an activity. I tried to create some listeners but that was taking too long to experiment. So I decided to drop it and use just wmctrl. also here I've added a screenshot from showDebugConsole method https://stackoverflow.com/questions/62863205/how-to-list-windows-per-kde-plasma5-activity |
Registered Member
|
Hi,
I'm kind of late to the party but this is something that's been disturbing me for a while as well. I tried just inspecting the window properties with `xprop` to see if there was anything in there that could be used to distinguish activities and found the `_KDE_NET_WM_ACTIVITIES` property. It contains the ID strings of all the activities a window is visible in (as a CSV value). You can use the dbus to query (see [here][https://unix.stackexchange.com/a/643945]) the current activity ID and use that to filter the windows. I tried amending a [script][https://github.com/mohkale/dotfiles/blob/be9636934eaa885c419cc4d7ee6a0771d400ed54/bin/app-windows#L1] I use to jump through terminal windows to only show windows in the current activity and it's working fine. This works for X, and while I'm not well versed on wayland I'm sure there's something similair for it. Let me know if someone comes up with something better but for now this works surprisingly well |
Registered users: abc72656, Bing [Bot], daret, Google [Bot], Sogou [Bot], Yahoo [Bot]