fdw / rofi-rbw

Rofi frontend for Bitwarden
https://github.com/fdw/rofi-rbw/
MIT License
192 stars 25 forks source link

xdotool type wrong passwords most of the time. #88

Closed nim65s closed 6 months ago

nim65s commented 8 months ago

Hi,

When xdotool type my password, the 2 first characters get uppercased, maybe ~75% of the time.

Fidling with XDoToolTyper, I noticed that removing the --delay 0 arguments seems to prevent this: https://github.com/fdw/rofi-rbw/blob/05e1d4d2c7e97cbb328543859ea91a3c478a7495/src/rofi_rbw/typer.py#L54-L55

fdw commented 8 months ago

--delay affects the time between keystrokes, so I guess when the typer starts you are releasing shift and it's only completely done after the second key was typed?

Removing the delay was added in #52, so I wouldn't want to remove it completely. We could make it configurable, but I'd prefer some solution that works around the problem. A xdotool keyup shift_l beforehand maybe?

nim65s commented 8 months ago

I should have mention that no, I clearly do not touch the Shift key at all: I run rofi-rbw -t password -a type --typer xdotool in a shell loop, only pressing Enter to select the first entry each time, and looking at the result.

xdotool keyup shift_l doesn't help, nor run(["xdotool", "keyup", "Shift_L", "Shift_R", "Alt_L", "Alt_R"]) before and after the main xdotool command in type_characters().

nim65s commented 8 months ago

Also, I did try with different delay settings, and in my case it looks like the issue is still triggered very often at 5, but I can't reproduce it at 6.

fdw commented 8 months ago

That helps, thank you very much! πŸ™‚

Can you maybe share some "password" that triggers this for you? Which of the first letters should be capitalized and which should be lower case?

nim65s commented 8 months ago

Sure, IΒ ran pwgen, and got the first result with lower cases first: nei8daiK. Then, selecting this test one on rofi with for i in (seq 10); rofi-rbw -t password -a type --typer xdotool; end, I get:

nei8daiKNEI8daiKnei8daiKNEI8daiKnei8daiKnei8daiKNEI8daiKNEI8daiKNEI8daiKNEI8daiK

The first is OK, but the second is not.

(this is fish syntax)

nim65s commented 8 months ago

Oh, this might be because there is a digit after the 3 first lowercases (which gets wrongly uppercased sometimes here), and on my keyboard layout, shift is required for digits. After a setxkbmap us, I have a correct 10/10 nei8daiKnei8daiKnei8daiKnei8daiKnei8daiKnei8daiKnei8daiKnei8daiKnei8daiKnei8daiK.

So my usual layout is setxkbmap fr bepo, but setxkbmap fr also trigger the issue.

fdw commented 8 months ago

Okay, that is interesting. I'm wondering if it's because of the number (but then shift would have to be applied too early) or because of the K at the end. Can you reproduce it without a number, just an upper case letter at the end?

What would your preferred solution be? I think the arguments from #52 are still valid, but rofi-rbw not working is also not acceptable. I'm leaning towards a small delay of 5 or 6, but what do you think?

polyzen commented 7 months ago

Changing it to 6 seems to have made a difference for me. There are still occasions where I have to retry pasting.

fdw commented 7 months ago

You have the same problem of xdotool upper casing some characters? Do you also use a non-US keymap?

Does a larger delay than 6 work better for you?

polyzen commented 7 months ago

You have the same problem of xdotool upper casing some characters? Do you also use a non-US keymap?

Was that the issue? I use a US keymap.

Does a larger delay than 6 work better for you?

Have not tried yet.

fdw commented 7 months ago

I thought the problem was related to the keymap, like @nim65s wrote:

After a setxkbmap us, I have a correct 10/10

At least, I have no other explanation why xdotool would reproducibly upper case the first letters characters by itself.

However, if you have the same problem, but with a US keymap, it has to be something different πŸ˜•

polyzen commented 7 months ago

I thought the problem was related to the keymap, like @nim65s wrote:

After a setxkbmap us, I have a correct 10/10

At least, I have no other explanation why xdotool would reproducibly upper case the first letters characters by itself.

However, if you have the same problem, but with a US keymap, it has to be something different πŸ˜•

Could just be human error on my part ┐('~`οΌ›)β”Œ

fdw commented 7 months ago

Okay, so is the original problem (some letters are upper cased by rofi-rbw) still happening for someone? If so, is a delay of 5 or 6 enough?

Or is there some other solution?

polyzen commented 7 months ago

IIRC I had tried 5 and found 6 to work better.

fdw commented 6 months ago

I've pushed something to main where you can define the delay with --typing-key-delay. It's still 0 by default, but you can change it if you experience problems.

Could you please test it and tell me if it works?

nim65s commented 6 months ago

I just removed the comments of lines "--delay" and "0" on the setup of mine that was having the issue, and I can't reproduce it anymore, so I can't properly test main, sorry. But I think 714e8fc24373e209857f9b0b9361b9bcd74bfdfb is a nice idea, and I will use it if I get this issue again, thanks a lot !

I think we can close this issue, then, unless somebody else currently can reproduce the issue, and report that 714e8fc24373e209857f9b0b9361b9bcd74bfdfb is not working.