我正在尝试编写一个脚本,如果应用程序未运行则启动该应用程序,或者如果该窗口在当前事件中可见则激活该窗口。
使用 xdotool
或 wmctrl
我能够获取窗口列表并激活它们。如果它们没有打开,那么我可以启动它们。但问题来自于 KDE 事件。这些工具列出所有事件的窗口,即使它们在当前事件中不可见。
我正在研究各种 qdbus 方法,但没有找到任何接近的方法。
有人创建过这样的脚本吗?如何获得有关事件的窗口可见性?
编辑: 如下图所示,我能够看到窗口附加到的事件 ID。但是我找不到任何方法以编程方式获取它。
最佳答案
给出了另一种方法 in kde forum .但是否能帮助解决您的问题尚不完全清楚。
推荐如下:
On the activity level you can make use of URI > Activity relations and query dbus for further scripting. For example:
- Link a directory to an activity in dolphin.
- Add an application "dolphin-directive" to application launcher and make it run a custom script to conditionally start dolphin instances.
- Set "dolphin-directive" as default filemanager
A similar workflow is possible for each filetype via File Association Settings
据我通过实验发现,不可能通过 ActivityManager 将窗口链接到事件和查询关系。我猜 multiple-screen-workspace-uri-activity-window-rule 架构应该设置工作流以更全面的方式解决问题。但希望有人能在这里给出更好的答案。
I wrote a script正则表达式检查整个 session 总线树的相关和有用的方法。您可以通过 ./query-dbus.py --pattern "^.*activit.*$"
简单地使用它。所以答案还在进行中。
编辑:一些服务确实有方法 isMonitorActivity
, isOnActivity
"org.kde.konsole": {
"/Sessions/1": {
"org.kde.konsole.Session": {
"method": [
"setMonitorActivity",
"isMonitorActivity"
]
}
}
}
"org.kde.kate": {
"/MainApplication": {
"org.kde.Kate.Application": {
"method": [
"isOnActivity"
]
}
}
}
}
您是否已提交功能请求?
关于kde-plasma - 如何列出每个 KDE/Plasma5 事件的窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62863205/