背景:我正在开发一个名为ActivityWatch的软件,该软件可以记录您在计算机上所做的工作。基本上是尝试解决以下问题:RescueTime,selfspy,arbtt等。

我们要做的核心工作之一是记录有关 Activity 窗口的信息(类和标题)。过去,这是在Linux上使用xprop和python-xlib毫无问题地完成的。

但是现在我们遇到了一个问题: Wayland正在兴起,据我所知,Wayland没有 Activity 窗口的概念。因此,我担心我们将不得不为Wayland可用的每个桌面环境实现支持(假设它们将提供获取有关 Activity 窗口的信息的功能)。

希望他们最终会聚在一起并拥有一些通用的界面来完成此操作,但是我不会屏住呼吸...

我去过anticipating this issue。但是今天,我们是由Wayland的实际用户获得的first user request for Wayland support。随着更大的发行版将Wayland用作默认显示服务器协议(protocol)(Fedora 25已经在使用它,Ubuntu将在即将推出的17.10中进行切换),随着时间的推移,情况将变得越来越关键。

ActivityWatch的相关问题:

  • https://github.com/ActivityWatch/aw-watcher-window/issues/18
  • https://github.com/ActivityWatch/activitywatch/issues/92

  • 像ActivityWatch这样的其他应用程序也需要相同的功能(RescueTime,arbtt,selfspy等),它们似乎暂时不支持Wayland,而且我找不到计划这样做的任何详细信息。

    我现在对实现对Gnome的支持感兴趣,以便从开始,并随着路径的发展变得更加清晰。

    关于韦斯顿的类似问题已在此处提出:get the list of active windows in wayland weston

    编辑:我在Freenode上的#wayland中询问,得到以下答复:

    15:20:44  ErikBjare    Hello everybody. I'm working on a piece of self-tracking software called ActivityWatch (https://github.com/ActivityWatch/activitywatch). I know this isn't exactly the right place to ask, but I was wondering if anyone knew anything about getting the active window in any Wayland-using DE.
    15:20:57  ErikBjare    Created a question on SO: https://stackoverflow.com/questions/45465016/how-do-i-get-the-active-window-on-gnome-wayland
    15:21:25  ErikBjare    Here's the issue in my repo for it: https://github.com/ActivityWatch/activitywatch/issues/92
    15:22:54  ErikBjare    There are a bunch of other applications that depend on it (RescueTime, selfspy, arbtt, ulogme, etc.) so they'd need it as well
    15:24:23  blocage      ErikBjare, in the core protocol you cannot know which windnow has the keyboard or cursor focus
    15:24:39  blocage      ErikBjare, in the wayland core protocol *
    15:25:10  blocage      ErikBjare, you can just know if your window has the focus or not, it a design choise
    15:25:23  blocage      avoid client spying each other
    15:25:25  ErikBjare    blocage: I'm aware, that's my reason for concern. I'm not saying it should be included or anything, but as it looks now every DE would need to implement it themselves if these kind of applications are to be supported
    15:25:46  ErikBjare    So wondering if anyone knew the teams working with Wayland on Gnome for example
    15:26:11  ErikBjare    But thanks for confirming
    15:26:29  blocage      ErikBjare, DE should create a custom extension, or use D-bus or other IPC
    15:27:31  blocage      ErikBjare, I guess some compositor are around here, but I do not know myself if there is such extension already
    15:27:44  blocage      compositor developers *
    15:28:36  ErikBjare    I don't think there is (I've done quite a bit of searching), so I guess I need to catch the attention of some DE developers
    15:29:16  ErikBjare    Thanks a lot though
    15:29:42  ErikBjare    blocage: Would you mind if I shared logs of our conversation in the issue?
    15:30:05  blocage      just use it :) it's public
    15:30:19  ErikBjare    ty :)
    

    编辑2:提交了enhancement issue in the Gnome bugtracker

    tl;博士:使用Wayland时如何在Gnome上获得 Activity 窗口?

    最佳答案

    前面的两个答案已经过时,这是在(Gnome)Wayland中查询应用程序名称和窗口标题的当前状态。

  • 一个特定于Gnome的JavaScript API,可以通过DBus访问
  • wlr-foreign-top-management Wayland协议(protocol)(不幸的是,未由Gnome实现)

  • 特定于Gnome的API可能会在Gnome版本之间中断,但它可以工作。它在很大程度上依赖于Gnome内部API的工作,因此没有机会成为标准API。有a PR on aw-watcher-window to add this,但是如果可能的话,它需要一些清理和afk支持。
    wlr-foreign-toplevel-management协议(protocol)(在撰写本文时)由Sway,Mir,Phosh和Wayfire合成器实现。与Wayland合成器广泛实现的idle.xml协议(protocol)一起,在aw-watcher-window-wayland中有一个完整的带有ActivityWatch的afk-detection的实现。我一直在与sway/rootston开发人员讨论过Wayland应用程序名称和X11 wm_class是否可互换,并且Sway和Phosh现在都可以互换使用,因此API中Wayland和XWayland窗口之间不再存在任何可区别的区别。
    我还没有研究过KWin是否具有类似于Gnome Shell的API来获取应用程序名称和标题,但它至少没有实现wlr-foreign-toplevel-management。

    10-04 13:49