Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to replace aw-watcher-window? #79

Closed
flexagoon opened this issue Dec 8, 2022 · 14 comments
Closed

Is it possible to replace aw-watcher-window? #79

flexagoon opened this issue Dec 8, 2022 · 14 comments

Comments

@flexagoon
Copy link

flexagoon commented Dec 8, 2022

I use GNOME Wayland, and aw-watcher-window doesnt work on that, so I'm creating a simple GNOME extension that would get the active window title via GNOME's API, like in #46. The aw-client-js library can't be easily used in GJS, so the actual watcher will be made in Python and communitcate with the extension via D-Bus.

However, the question is, is it possible for users to replace aw-watcher-window? What I mean is some sort of a config to prevent aw-watcher-window from starting automatically and starting a custom version (eg. aw-watcher-window-gnome) instead.

@flexagoon
Copy link
Author

Oh, never mind. I found the autostart_modules option in the config.

@johan-bjareholt
Copy link
Member

@flexagoon I've already tried this, the D-Bus API is locked down in newer versions of gnome-shell, so only the xdg-desktop-gnome process is allowed to talk with it unless you fork the code. flatpak/xdg-desktop-portal#304 (comment)

Long-term the best solution is probably to make an xdg-desktop-portal PR with a suggestion on an API and an PR to xdg-portal-gnome with an prototype implementation and then discuss further from there.

@johan-bjareholt
Copy link
Member

However, the question is, is it possible for users to replace aw-watcher-window? What I mean is some sort of a config to prevent aw-watcher-window from starting automatically and starting a custom version (eg. aw-watcher-window-gnome) instead.

I've done this for about 2 years with aw-watcher-window-wayland for phosh based compositors, works very well.
https://github.com/activitywatch/aw-watcher-window-wayland

@flexagoon
Copy link
Author

the D-Bus API is locked down in newer versions of gnome-shell, so only the xdg-desktop-gnome process is allowed to talk with it unless you fork the code

@johan-bjareholt what do you mean? Other applications should be able to talk to D-Bus, otherwise there would be no point in D-Bus. And I'm not calling the "active window" API directly, I made an extension that wraps this in a different D-Bus query

@johan-bjareholt
Copy link
Member

johan-bjareholt commented Dec 10, 2022

@flexagoon D-Bus is for inter process communication yes, but that does not mean that any application is allowed to talk to any D-Bus service due to security. And in this case, instead of using the normal D-Bus policyxml files for D-Bus permissions, they've hardcoded the permissions in the app so you can't change them without recompiling the app. The only process allowed to use the API is xdg-desktop-portal-gnome. This was stated in the link I sent earlier in the xdg-desktop-portal issue.

@johan-bjareholt
Copy link
Member

And I'm not calling the "active window" API directly, I made an extension that wraps this in a different D-Bus query

What do you mean exactly? Which API are you using then?

@flexagoon
Copy link
Author

What do you mean exactly? Which API are you using then?

@johan-bjareholt the active window API can't be called by other apps due to security, but it can be called by GNOME Shell extensions. Extensions can also define their own DBus schemas, and apply their own security policies to them. So you can create an extension that defines a DBus function which everyone can call, and when that function gets called the extension runs the active window api and returns the result of that.

@flexagoon
Copy link
Author

Here's an example of an extension that exposes private APIs as public DBus queries

https://github.com/ickyicky/window-calls

@johan-bjareholt
Copy link
Member

Aha, that makes sense!
I was a bit confused before when you were talking about D-Bus, as I was for some reason assuming that you meant the gnome-shell Introspection D-Bus interface.

In that case why even make a new watcher, why not try to integrate it straight into aw-watcher-window?
Another option would be to implemented it into aw-watcher-window-wayland, then you would get AFK support as well and have a complete solution for GNOME under wayland (as I believe that gnome-shell implements the idle.xml wayland protocol, which aw-watcher-window-wayland uses). I could even implement the whole watcher part in aw-watcher-window-wayland if you want, as long as you implement the gnome-extension part as that's outside of my expertise.

@johan-bjareholt
Copy link
Member

johan-bjareholt commented Dec 13, 2022

Another option would be to just skip implementing an extension completely, and just re-use the window-calls extension. It already supports the List method which is all we need.

@flexagoon
Copy link
Author

@johan-bjareholt I already implemented the extension https://github.com/flexagoon/focused-window-dbus

I also already made the watcher and I'm using it on my machine. I'll do some polishing and upload it to Github. I don't know any Rust though, so I'm not able to add it to aw-watcher-window-wayland myself unfortunately, you'll have to do this if you want to

I also don't know whether GNOME supports idle.xml or not, I wasnt able to find any information on that. I just found that GNOME has a "time since last input" D-Bus query so I used that.

@flexagoon
Copy link
Author

@johan-bjareholt I released aw-watcher-gnome here:

https://github.com/flexagoon/aw-watcher-gnome

@igorcafe
Copy link

no workaround on plasma yet, right?

@flexagoon
Copy link
Author

no workaround on plasma yet, right?

@igorcafe awatcher supports plasma

https://github.com/2e3s/awatcher

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants