keepassxreboot / keepassxc

KeePassXC is a cross-platform community-driven port of the Windows application “Keepass Password Safe”.
https://keepassxc.org/
Other
20.82k stars 1.44k forks source link

AutoType not available when using Wayland #2281

Open ganomi46 opened 6 years ago

ganomi46 commented 6 years ago

Expected Behavior

AutoType should be available as under X.

Current Behavior

AutoType not available in Wayland

Steps to Reproduce (for bugs)

Login to Plasma Wayland Open KeePassXC You will there are no auto login options

Operating system: OS Debian SID amd64

rldleblanc commented 2 years ago

As a follow-up, GDK_BACKEND=x11 did not seem to work and to update the Application Menu item, I had to enter env WAYLAND_DISPLAY=no keepassxc %f in the Command section. Hopefully that will help buy some time and still be able to test/use Wayland.

rusty-snake commented 2 years ago

GDK_BACKEND=x11 did not seem to work

Because kpxc is a Qt app and not a GTK one. QT_QPA_PLATFORM=xcb is the right environment variable. See https://wiki.archlinux.org/title/Wayland#Qt.

As a work around for KDE on Wayland (Debian Bookworm) is to run KeepassXC through Xwayland.

As long as you only need to auto-type into XWayland clients yes but if you need to auto-type into native Wayland clients ...

rldleblanc commented 2 years ago

You are correct. I thought I read that Google Chrome was defaulting to Wayland (which it is not) and so when it worked I thought there was something there. Starting Chrome with Wayland did not allow AutoType to work (neither did Konsole work). I thought after a few years I would give Wayland a try, it didn't crash immediately and Dvorak now worked, but I think I will try it again in a few years.

dimztimz commented 2 years ago

Keyboard input is actually not the challenge here. The issue is window title harvesting and ability to read the window title to use global auto type capability. That is currently impossible through the Wayland protocol and no Wayland based compositors have exposed this as a standard or defined interface.

Maybe you can first try to implement auto-type of manually selected entry (right click -> Perfom Auto-Type). Is that a problem with Wayland because it requires focusing the previously focused window?

droidmonkey commented 2 years ago

Yes it is for that very reason. Although we can just minimize our own window and hope the focus shifts correctly.

dimztimz commented 2 years ago

Just to recap, there are 3 problems related to this issue.

  1. Keyboard input. There are multiple approaches for solving this. One is by using /dev/uinput. See how KeePass does it https://keepass.info/%0D/help/kb/autotype_wayland.html or a comment above or some stackoverflow. Does Qt has something for this? Maybe use the clipboard instead of simulating keyboard input? Libei?
  2. Focusing the last focused window. What is used now? What does KeePass do? Does it minimizes the window?
  3. Reading the titles of the windows. There is no straightforward solution for this.

Feature 1 and 2 are needed for auto-type of selected entry, 1 and 3 are needed for global auto-type. Did I missed something?

droidmonkey commented 2 years ago

Registering a global shortcut, but that might be covered by existing Wayland api. Most likely not, which would make it desktop env specific. /dev/uinput is not an option, requires root.

rusty-snake commented 2 years ago

Registering a global shortcut, but that might be covered by existing Wayland api. Most likely not, which would make it desktop env specific.

FWIW https://github.com/flatpak/xdg-desktop-portal/issues/624

ibahnasy commented 2 years ago

This is also affected in Gnome (Ubuntu 22.10).

cskr commented 2 years ago

Auto-type from context menu used to work fine when running Firefox under xwayland, but even this has stopped working since 2.7.0.

dasistwas commented 2 years ago

Ubuntu 22.04 Beta, Keepassxc 2.7.0:

tmccombs commented 2 years ago

@dasistwas that is likely because Signal and Chromium are using XWayland, but Firefox, Terminal, and Thunderbird are using native wayland.

dasistwas commented 2 years ago

Update from Ubuntu 22.04 Beta: Suddenly auto-type started to work. But version of keepassxc did not change. It is still 2.7.1

ourichermath commented 2 years ago

I'd like to request the documentation at:

https://keepassxc.org/docs/KeePassXC_UserGuide.html#_auto_type

be added to. I'm on Fedora (Wayland) and it was really difficult to figure out where and how to change either the command line (-platform xcb) for my KeepassXC that was set to Autorun or the environment variable (QT_QPA_PLATFORM=xcb). Some mention of where and how would be nice.

Also, the documentation isn't clear in what KPXC is looking for with AutoType to work with applications. For instance, when I try to set it up to work with the password entry in the Virtual Machine Manager or for Grsync, the window names don't show up in KPXC's Advanced > Windows dropdown. And, no matter what I manually type in for a Window name, it doesn't work.

foobar13372 commented 2 years ago

Ubuntu 22.04 + snap version of Firefox (Ubuntu 22.04 upgrademigrates FF to the snap version automatically): autotype works again. Did not test other programs since I only need keepass for Firefox.

ibahnasy commented 2 years ago

Wayland is disabled by default in 22.04 because of a bug, may be that's why autotype is working?

------- Original Message ------- On Friday, April 22nd, 2022 at 8:39 AM, foobar13372 @.***> wrote:

Ubuntu 22.04 + snap version of Firefox (Ubuntu 22.04 upgrademigrates FF to the snap version automatically): autotype works again. Did not test other programs since I only need keepass for Firefox.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

dasistwas commented 2 years ago

Wayland is disabled by default in 22.04 because of a bug, may be that's why autotype is working?

no, I am on Wayland. But just realized seems only Firefox and xwayland programs do work with autotype. Terminal does not for example.

tmccombs commented 2 years ago

only Firefox and xwayland programs is firefox using xwayland?

dinotheextinct commented 2 years ago

Is there any news to this? I am on sway and would like to know how I can get autotype working for firefox. Setting the xcb plattform, enables autotype, but hitting the configured shortcut from keepassxc for autotype doesnt open anything.

Zocker1999NET commented 2 years ago

but hitting the configured shortcut from keepassxc for autotype doesnt open anything.

As I know it, Sway does not allow other applications to apply global shortcuts themselves and also I do not know of any Wayland protocol which would implement this. It might be required to configure the shortcut on Sway manually and trigger AutoType on KeePassXC using a command / D-Bus (which is not possible yet?)

siccovansas commented 2 years ago

I recently installed Ubuntu 22.04 and ran into this issue.

Firefox and Chromium apparently use XWayland, so KeePasXC's Global Auto-Type works there.

My main other use of Auto-Type is in the terminal for which I use the Terminator terminal. I use the following (hopefully temporary) workarounds to run Terminator using XWayland when using the Ctrl + Alt + T shortcut and when starting Terminator via its icon in the launcher:

dinotheextinct commented 2 years ago

Not sure if this is some Gnome garbo, but under KDE Wayland, KeepassXC doesnt even offer the Autotype option??

rusty-snake commented 2 years ago

https://github.com/keepassxreboot/keepassxc/blob/861fe2e5a9ec1025f89591b14017fc3880fb3733/docs/topics/AutoType.adoc?plain=1#L10

dinotheextinct commented 2 years ago

So I got the autotype option back, but when hitting the shortcut, there is no popup on wayland, when using it for firefox...

ibahnasy commented 2 years ago

I can confirm that auto typing is currently working in Wayland normally after the past system updates released in the past few weeks.

dasistwas commented 2 years ago

I can confirm that auto typing is currently working in Wayland normally after the past system updates released in the past few weeks.

Did you test autotype with the terminal as well? Only xwayland programs seem to work. All wayland windows do not trigger the autotype dialogue when using the global autotype shortcut.

ibahnasy commented 2 years ago

I can confirm that auto typing is currently working in Wayland normally after the past system updates released in the past few weeks.

Did you test autotype with the terminal as well? Only xwayland programs seem to work. All wayland windows do not trigger the autotype dialogue when using the global autotype shortcut.

It doesn't work with the terminal. Triggering the autotype from the KPXC window or using the keyboard key combination, it works fine with some GUI apps like Google Chrome, but apps like FIrefox or Nautilus doesn't work.

pio2398 commented 2 years ago

I can confirm that auto typing is currently working in Wayland normally after the past system updates released in the past few weeks.

Did you test autotype with the terminal as well? Only xwayland programs seem to work. All wayland windows do not trigger the autotype dialogue when using the global autotype shortcut.

It doesn't work with the terminal. Triggering the autotype from the KPXC window or using the keyboard key combination, it works fine with some GUI apps like Google Chrome, but apps like FIrefox or Nautilus doesn't work.

It's just can't work with wayland app. Could you read at least few comment back before posting? https://github.com/keepassxreboot/keepassxc/issues/2281#issuecomment-831369450

bigdiff commented 2 years ago

Would it be possible to implement a workaround for now till xdg-desktop-portals implements a global shortcut portal.

I was thinking about making keepassxc launch with a --auto-type flag. Adding that to the list of custom shortcuts in gnome-control-panel would resolve the issue for now.

name: KeePassXC Auto-Type
command: keepassxc --auto-type

gnome control center > add custom shortcuts

vimpostor commented 2 years ago

Would it be possible to implement a workaround for now till xdg-desktop-portals implements a global shortcut portal.

Can you guys at least read through the thread before pushing this again. Even if you fix the shortcut registering, you still can't find out the title of the window.

And again, the easiest way to move this issue forward is to move the already existing upstream proposals forward:

Why are people pushing this issue every week but not the real underlying issue in the upstream protocols? This is all so backwards. Quite frankly, this issue should be closed as "Won't fix" or locked until this mess is fixed in Wayland. Originally back in 2013 Wayland was meant to cut out the "useless" middleman, ironically now we end up with even more useless middlemen just to deal with basic stuff like negotiating shortcut registering or server side decorations.

droidmonkey commented 8 months ago

This information was provided by @galaxysnail

Currently, we have the global keyboard shortcut portal and libei, which should be good enough for auto-type.

For enumerating windows, there is a foreign toplevel list protocol.

droidmonkey commented 3 months ago

Just learned that Goldwarden is using the libportal RemoteDesktop interface for auto-type. Unsure on the actual security of that, but here it is:

https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.RemoteDesktop.html

https://github.com/quexten/goldwarden/blob/main/cli/autotype/libportalautotype.go

Thatoo commented 3 months ago

On Gnome 46, I now have a new windows asking me if I want to authorized the operation but after syaing yes, nothing more happen. Normal?

droidmonkey commented 3 months ago

Gnome added that

Thatoo commented 3 months ago

It doesn't help to make AutoType working on Wayland yet?

sagebind commented 3 months ago

No. KeePassXC will have to implement something new for AutoType to work on Wayland (even if what that is exactly is not clear). There's no way that KeePassXC's existing X11 code will "magically" work with Wayland someday.

Zahrun commented 3 months ago

I’m offering $100 for a fix to this issue at gitpay https://gitpay.me/#/task/763/auto-type-not-available-when-using-wayland If this issue is important to you, please feel free to add any amount to the bounty.

TheConfuZzledDude commented 3 months ago

Just learned that Goldwarden is using the libportal RemoteDesktop interface for auto-type. Unsure on the actual security of that, but here it is:

https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.RemoteDesktop.html

https://github.com/quexten/goldwarden/blob/main/cli/autotype/libportalautotype.go

I believe that using the RemoteDesktop portal interface is fine for that, it's really just for accessing emulated inputs. The ConnectToEIS would be used to get the fd for the compositor's EIS, and then libei can be used to actually send inputs.

See also https://libinput.pages.freedesktop.org/libei/api/index.html#sec-oeffis for liboeffis which handles the desktop portal access and just gets the libei fd.

As for window detection/focusing, ext-foreign-toplevel-list-v1 isn't really implemented anywhere yet, and activation of those foreign windows isn't close.

zsteinmetz commented 3 months ago

I’m offering $100 for a fix to this issue at gitpay https://gitpay.me/#/task/763/auto-type-not-available-when-using-wayland If this issue is important to you, please feel free to add any amount to the bounty.

Just added 50 bucks :money_with_wings:

zsteinmetz commented 3 months ago

@droidmonkey, could you please add the bounty tag and the current amount to this issue to raise more awareness? Thank you!

droidmonkey commented 3 months ago

We don't officially back bounties anymore, but I added the tag for sport.

TheConfuZzledDude commented 3 months ago

I am working at this currently, I'll have a WIP PR up soonish

TheConfuZzledDude commented 3 months ago

The PR is up now, still needs work

reshadp commented 1 month ago

When I run KeePassXC from the terminal using the command keepassxc -platform xcb I have get the auto type options enabled again (I know this is supposed to work). I am on KDE Plasma 6 running Wayland and am able to use the autotype function when in this mode to type into even what should be Wayland windows (Konsole, Kate, Kwrite, Firefox) after accepting a dialogue box which asks me to accept a remote control request. Screenshot_20240722_120525 The dialogue box only shows up once per Plasma session (which I think is fine).

This dialogue box is relatively new (maybe a month or so) auto-type would only work with X11 apps running in XWayland (I used to auto-type into Chromium) before I noticed this dialogue box. Hope this workaround helps anyone while the PR to get this properly implemented.

agowa commented 1 month ago

The documentation already coveres this: https://keepassxc.org/docs/KeePassXC_UserGuide#_auto_type

Auto-Type will be disabled when run with a Wayland compositor on Linux. To use Auto-Type in this environment, you must set QT_QPA_PLATFORM=xcb or start KeePassXC with the -platform xcb command-line flag.

After testing this right now I only see two minor issues remaining to be fixed regarding this ticket:

vimpostor commented 1 month ago

I feel there is a need to explain why suddenly the XWayland -> Wayland client direction is working without changes from the Keepass side and why the problem is still only half solved:

The "Remote control requested" dialog you are seeing is a result of KDE implementing the Input Capture and Remote Desktop portal together with support for the ConnectToEIS method.

libei is a library for emulated input on Wayland and has support for a superset of the functionality that was available in the XTest extension, which KeepassXC uses to implement autotype on X11.

libei can be used as a drop-in replacement for XTest in XWayland and the README even illustrates this architecture. Note that the comment about the implementations being in PoC state is outdated, full support was merged into XWayland a year ago.

This means that the fully working path from XWayland to Wayland clients is as follows:

As mentioned at the beginning, there are however some caveats with this:

  1. This only works if KeepassXC is running in XWayland mode, there is no native Wayland support yet (however there is a PR being worked on).
  2. It does not support filtering based on Window titles. This means it is not possible to hit a global key and show entries based on the currently active window, as is possible with Xorg. Instead the entry has to be manually selected. This caveat will also still be true for the pending native Wayland PR, there simply is no mechanism on Wayland to do that (and many compositors even refuse to implement ext-foreign-toplevel-list-v1)
  3. The dialog asking for input consent will silently swallow all sent input events until the dialog is accepted, so on the first time the target may receive only half or none of the intended keyboard events.

So while the situation is certainly better than before (support for basic autotype is working in XWayland and soon in Wayland), full support like on Xorg with autotype triggered on a hotkey and automatically filtering based on window title is still far from a reality.

agowa commented 1 month ago

@vimpostor is https://wayland.app/protocols/ext-foreign-toplevel-list-v1#ext_foreign_toplevel_handle_v1:event:title part of the accessibility API? Getting information of running windows sounds like something almost every accessibility tool would need to function properly. And doesn't Wayland at least also have support for screen readers? How do they access such information then? Doesn't Orca Screen Reader already support Wayland? So aren't there already APIs that could be used?

Or is this all still a big work in progress mess?

MRDGH2821 commented 1 month ago

This seems to be useful: https://espanso.org/docs/install/linux/#adding-the-required-capabilities

Ironwally commented 1 month ago

I found this issue after installing keepassxc via snap. Up to now I used keepassxc via appimage. Here I did not have any issues or needed workarounds.

So maybe it would be interessting to know why this works with the appimage, but not with, I suppose, the rest?

MRDGH2821 commented 1 month ago

I found this issue after installing keepassxc via snap. Up to now I used keepassxc via appimage. Here I did not have any issues or needed workarounds.

So maybe it would be interessting to know why this works with the appimage, but not with, I suppose, the rest?

You mean to say that Auto type works in wayland session when run as app image? Because I tried & there is no Autotype option.

Can you confirm if you were in Wayland/X11 session?