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

Silently fails under Linux if xwininfo/xprop is missing #75

Open
QbDesu opened this issue Jul 10, 2020 · 4 comments
Open

Silently fails under Linux if xwininfo/xprop is missing #75

QbDesu opened this issue Jul 10, 2020 · 4 comments

Comments

@QbDesu
Copy link

QbDesu commented Jul 10, 2020

Fails without further notice if xprop or xwininfo because they are either not installed, or not present in the PATH variable. If you ask me the promise should fail with a proper error when something fails (or throw an Error for the sync variant). The current behaviour makes debugging the root of the problem quite difficult.

https://github.com/sindresorhus/active-win/blob/430e6efc02823c1b04331a987012a519c360ab23/lib/linux.js#L109-L111

Also you might want to add that there is no Wayland support at the moment to the documentation especially considering the increasing popularity of Wayland.

I might PR this myself when I find the time.

@QbDesu QbDesu changed the title Silently fails if xwininfo/xprop is missing Silently fails under Linux if xwininfo/xprop is missing Jul 10, 2020
@sindresorhus
Copy link
Owner

I don’t use or have Linux, but a PR is welcome to improve the behavior.

@tkainrad
Copy link
Contributor

The ActivityWatch project has a similar problem with Wayland: ActivityWatch/activitywatch#92

So far, they seem to have found a workaround for Gnome.

This shell command can retrieve the active Window application name for Wayland + Gnome:

gdbus call -e -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval global.get_window_actors\(\)[`gdbus call -e -d org.gnome.Shell -o /org/gnome/Shell -m org.gnome.Shell.Eval global.get_window_actors\(\).findIndex\(a\=\>a.meta_window.has_focus\(\)===true\) | cut -d"'" -f 2`].get_meta_window\(\).get_wm_class\(\) | cut -d'"' -f 2

If there are no other options, this might be an approach to support a large portion of Wayland users.

@binyamin
Copy link
Contributor

@sindresorhus I can confirm that, on Wayland, this is impossible by design. It's a security measure, meant to prevent windows from spying on each other. See https://stackoverflow.com/questions/4546501

PR incoming 😃

@tkainrad According to this StackExchange answer, Gnome 41 doesn't allow that workaround anymore.

@accerqueira
Copy link

accerqueira commented Apr 28, 2022

Although Wayland doesn't support EWMH/ICCCM by design, Wayland compositors may provide equivalent functionality, like wlr-foreign-toplevel-management.
This might inspire a future PR: https://github.com/activitywatch/aw-watcher-window-wayland

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

No branches or pull requests

5 participants