firecat53 / keepmenu

Dmenu/Rofi frontend for Keepass databases
GNU General Public License v3.0
204 stars 32 forks source link

Possible locale issue pasting passwords #152

Closed PhilT closed 1 year ago

PhilT commented 1 year ago

So I've got a password that has a # and " in it. When selected from keepmenu they appear as \ and @ respectively.

My locale is en_GB.

ANG=en_GB.UTF-8
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER="en_GB.UTF-8"
LC_NAME="en_GB.UTF-8"
LC_ADDRESS="en_GB.UTF-8"
LC_TELEPHONE="en_GB.UTF-8"
LC_MEASUREMENT="en_GB.UTF-8"
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=
firecat53 commented 1 year ago

We also need to know what launcher and what type library you are using. Does it behave the same when using the clipboard feature --clipboard-- or a different launcher/type library?

PhilT commented 1 year ago

Sorry, I'm using dmenu with pynput. I'm using the package from https://github.com/NixOS/nixpkgs/blob/nixos-23.05/pkgs/applications/misc/keepmenu/default.nix#L32 but overridden to the latest release, 1.4.0. I'm not sure how to use the clipboard feature but if I go to View entry and select the password that way, it pastes it correctly. It must just be when using the autotype feature.

I tried installing xsel but that didn't seem to help. I have xclip installed already so I assume it's using that.

Cheers, Phil

firecat53 commented 1 year ago

Can you please try installing and changing type_library in the the config to xdotool (I'm assuming you're on X and not Wayland)? Thanks!

PhilT commented 1 year ago

Thanks for your suggestion. Yes, I'm on X. I tried xdotool and it did indeed fix the password issue. However, the @ in the email address is being replaced with a q. How weird?!

PhilT commented 1 year ago

Looks like I might be able to work around it: https://github.com/jordansissel/xdotool/issues/49

PhilT commented 1 year ago

And indeed, if I run setxkbmap before keepmenu the output is correct.

PhilT commented 1 year ago

Chucked that into the dwm autostart script and that's working for me. Thank you for your help. Really appreciate your efforts on this. It's a really nice tool. :+1:

firecat53 commented 1 year ago

I'd love to get your setup/configuration specifics so I can maybe write additional notes in the docs on how to use a non U.S. English keyboard layout! Thanks for the kind words :)

PhilT commented 1 year ago

So you can see my NixOS configuration (and the specific line where I set the locale) here on GitHub.

Here's an extract of the config:

  time.timeZone = "Europe/London";
  i18n.defaultLocale = "en_GB.UTF-8";
  console = {
    packages=[ pkgs.terminus_font ];
    font="${pkgs.terminus_font}/share/consolefonts/ter-i18b.psf.gz";
    useXkbConfig = true;
  };
  services.xserver.layout = "gb";

Here's where I added the line to fix the issue: https://github.com/PhilT/nixos-files/blob/main/src/xserver.nix#L60

    systemPackages = [
      (pkgs.writeShellScriptBin "autostart.sh" ''
        /run/current-system/sw/bin/setxkbmap   # Fix an issue with characters getting switched when pasting text for keepmenu with xdotool
...

I'll follow up in a moment with some info prior to running the setxkbmap fix.

PhilT commented 1 year ago

Switching back to pynput the same fix worked. Running setxkbmap beforehand then outputs all the correct characters for email and password.

PhilT commented 1 year ago

Let me know if you need any more details.