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

Using xdotool for years on XWayland but now inhibited #346

Closed
bulletmark opened this issue Aug 4, 2021 · 21 comments · Fixed by #355
Closed

Using xdotool for years on XWayland but now inhibited #346

bulletmark opened this issue Aug 4, 2021 · 21 comments · Fixed by #355

Comments

@bulletmark
Copy link

Arch Linux updated to the new xdotool today (from version 3.20160805.1-3 to 3.20210804.2-1) and now xdotool terminates itself claiming it does not run on XWayland. However, myself and many others have been using xdotool with XWayland and libinput-gestures for very many years and it has always worked fine. Please consider removing that check and allowing the program to continue running as it previously did.

I fetched the latest xdotool sources, commented out that single return NULL, then rebuilt and it worked fine for all my key mappings.

Undoubtedly I acknowledge you have probably seen issues supporting some XWayland edge cases but to completely disallow xdotool usage seems an extreme approach. Perhaps output a disclaimer/warning that XWayland is not formally supported (and state that no issues should be raised?), but please allow us to continue using this extremely useful tool.

@jordansissel
Copy link
Owner

jordansissel commented Aug 4, 2021 via email

@bulletmark
Copy link
Author

bulletmark commented Aug 4, 2021

I have the following configuration in my libinput-gestures.conf file to allow gestures to work with Chrome browser and they work fine. Have been using them for years on GNOME with Wayland. Note that Chrome (and Firefox) runs via XWayland.

gesture swipe left	4	xdotool key alt+Right
gesture swipe right	4	xdotool key alt+Left
gesture swipe right_up	4	xdotool key control+Tab
gesture swipe left_up	4	xdotool key control+shift+Tab
gesture swipe left_down	4	xdotool key control+w
gesture swipe right_down 4	xdotool key control+shift+t

@bulletmark
Copy link
Author

bulletmark commented Aug 5, 2021

BTW, should make it clear that libinput-gestures does nothing special here and is kind of irrelevant. It simply executes the above commands when it sees the above touchpad gestures invoked, just as if those commands were run manually at the time.

@bulletmark
Copy link
Author

bulletmark commented Aug 5, 2021

To be very clear - of course xdotool does not work for any native Wayland applications, but it does work for all applications running via XWayland because that is just a regular X server where xdotool works fine. There are still plenty of apps (such as Chrome and Firefox at least) that run via XWayland within a user's Wayland session.

@jordansissel
Copy link
Owner

jordansissel commented Aug 5, 2021 via email

@bulletmark
Copy link
Author

The only comment I would make about the warning is that it is a little noisy. E.g. every time a user invokes one of the above touchpad gestures, which for me is many hundreds of time per day when using my browser, then xdotool is run and it will output that message to the user's journal.

@Redecorating
Copy link

I've also been using xdotool under xwayland, for discord push to talk, with this bit of sway config:

bindsym Alt_R exec xdotool keydown F30
bindsym --release --locked Alt_R exec xdotool keyup F30

I then bind F30 to push to talk within discord, and right-alt works as global push to talk.

Another option for allowing xwayland would be to have an argument like --enable-xwayland which would skip the xwayland check. (you could then alias xdotool to xdotool --enable-wayland if you always want it to work under wayland)

@shibe2
Copy link

shibe2 commented Aug 16, 2021

In my opinion, X clients, such as xdotool, should check advertised features rather than particular implementation. From this point of view, it would be best to just remove the unnecessary check.

xdotool works fine with XWayland, I haven't encountered a single operation that works with standalone Xorg and fails with XWayland. The only case when a warning would be warranted is when a user tries to interact with Wayland windows using X protocol. If you can detect that, good. Otherwise it's better to be quiet.

Wayland protocol can be used by X server to interact with hardware back-end while the user runs normal X session. This is suggested by X.org and Wayland developers. In this use case, there is no Wayland windows, and no X/Wayland confusion.

@jordansissel
Copy link
Owner

jordansissel commented Aug 16, 2021

I'm OK to remove the previous change (which now rejects XWayland). I'm considering making it a warning message.

xdotool works fine with XWayland

I'm glad this has been your experience! For me, I notice very quickly that I'm running Wayland. I noticed when Fedora switched to it and, more recently, when Ubuntu switched to it, primarily through noticing that xdotool stops doing working the way it was before an OS upgrade.

There are a variety of perspectives through which "xdotool works on Wayland" is a correct statement. Not everyone has this experience though, which is why I wrote the patch in the first place. For context, I will not expect any xdotool user to know that they're graphics environment is Wayland, nor will I expect anyone to understand the oddities of XWayland vs XOrg.

More research is likely needed to be able to detect and/or notify users about expected issues, especially since any suggested corrective action might be a larger burden such as switching to X11/Xorg.

@jordansissel
Copy link
Owner

Not sure why my previous comment got mangled (I sent via email). I've edited it now 😆 hopefully it makes more sense.

@jordansissel
Copy link
Owner

should check advertised features rather than particular implementation

I don't know if this is possible, in a sense.

For example, if you're running Nautilus (gnome's file manager) and want to use xdotool to perform some action, it will probably fail on Wayland. The failure would be that xdotool wouldn't be able to find nor interact with any Wayland surfaces, and I don't expect a user to know the details about Wayland vs XWayland and the areas around which xdotool would or would not work.

In this way, having xdotool detect "Are we running on XWayland?" is the only way I found to detect any such "advertised feature" we might describe as "Stuff you could expect to work, but doesn't work, because you're running on Wayland"

As for detecting XWayland, I only found two ways to detect it. One of them is used by the xinput tool upstream in the Xorg project which uses the xinput device listing to check if any input device has a name starting with "xwayland-".

@shibe2
Copy link

shibe2 commented Aug 16, 2021

I see a couple problems with warning:

  1. Just detection of XWayland is not a good trigger for it. I gave an example XWayland use case where Wayland protocol would not be available to client applications, and from user's point of view, everything works the same way as with other X servers. I myself use a Wayland compositor for features that standalone Xorg server doesn't have, but applications that I want to control use X protocol. There is no window for which xdotool would not work.
  2. In many use cases, xdotool is launched many times by scripts or other applications. Issuing the same warning on every invocation would clutter logs of legitimate users and bury actually useful messages.

When these problems are solved, it would be a good warning to have.

I will not expect any xdotool user to know that they're graphics environment is Wayland

The name of protocol is in the name of xdotool, so direct xdotool users should know about the protocols, in my opinion. Indirect users may not know, but perhaps, in this case, it is better to solve the problem in the applications that use xdotool. For example, a GUI applications can display information in the UI instead of writing warnings to stderr. A smart application can use xdotool for interacting with X windows and another tool for interacting with Wayland windows.

@jordansissel
Copy link
Owner

jordansissel commented Aug 17, 2021 via email

gentoo-bot pushed a commit to gentoo/gentoo that referenced this issue Aug 17, 2021
This will likely no longer be needed come next release - with users
generally reporting having been able to use xdotool on XWayland,
upstream has decided to change the behaviour of the newly added check
to "warn but allow". See
jordansissel/xdotool#346
for details.

Suggested-by: Duncan <1i5t5.duncan@cox.net>
Closes: https://bugs.gentoo.org/807989
Signed-off-by: Marek Szuba <marecki@gentoo.org>
@Algram
Copy link

Algram commented Aug 29, 2021

Yeah please re-enable it with wayland again. I've been using this with xwayland for years without problems. I actually had to downgrade xdotool after the wayland check was merged :)

Basically if you are running a wayland compositor, you will currently need both ydotool/wtyp and xdotool for wayland and xwayland windows respectively.

Here you can see an example of mine using it for inputting umlauts on sway:
image

@bulletmark
Copy link
Author

Users who come here from Arch, please note that another user has added a new xdotool-xwayland package to the AUR to work around this issue. Use yay -S xdotool-xwayland to install.

@jordansissel
Copy link
Owner

@bulletmark thanks for highlighting that for folks on Arch :)

I'm going to remove the fail-on-wayland stuff for now. Hopefully we can figure out how to approach "You're on XWayland and some stuff won't work" better next time.

jordansissel added a commit that referenced this issue Sep 3, 2021
This removes behavior introduced by #341.

After #341 was released, several folks reported that xdotool has indeed
worked correctly on XWayland in the past.

I've left the "is on wayland?" detection code that is otherwise now
unused, in case we want it later.

Fixes #346.
@jordansissel
Copy link
Owner

#355 should revert to the prior (working on XWayland).

We can keep it this way until we get a better idea of what scenarios and functionality do not work on XWayland and maybe bring some kind of warning for those scenarios.

jordansissel added a commit that referenced this issue Sep 3, 2021
This removes behavior introduced by #341.

After #341 was released, several folks reported that xdotool has indeed
worked correctly on XWayland in the past.

I've left the "is on wayland?" detection code that is otherwise now
unused, in case we want it later.

Fixes #346.
@bulletmark
Copy link
Author

@jordansissel are you planning to do a new release soon with that change?

@jordansissel
Copy link
Owner

@bulletmark indeed! Working on that now.

@bulletmark
Copy link
Author

Thanks very much. I have already flagged the Arch package to be updated soon hopefully.

buldi pushed a commit to buldi/xdotool that referenced this issue Apr 23, 2022
This removes behavior introduced by jordansissel#341.

After jordansissel#341 was released, several folks reported that xdotool has indeed
worked correctly on XWayland in the past.

I've left the "is on wayland?" detection code that is otherwise now
unused, in case we want it later.

Fixes jordansissel#346.
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

Successfully merging a pull request may close this issue.

5 participants