Makes typing a password painless when you write in more than one language: while you type a password the keyboard layout is Latin. If the current layout is not Latin, the one you used last is switched to, and your layout comes back when the password is done. For Hyprland with fcitx5; developed and tested on Omarchy, where both come out of the box.
If you type in a non-Latin layout, you know the routine: sudo asks for a
password, you type it blind, it is rejected, and only then do you notice the
layout was wrong.
The logic is the one macOS users are used to: in a password field only Latin layouts are allowed, and the switch there and back happens by itself.
- if the active layout is already Latin, nothing changes — German stays German;
- otherwise the Latin layout that was last in use is switched to, or the first Latin one if none has been used yet;
- when the password is done, the layout that was active before comes back.
A layout is Latin if it types the letters a–z: German, Dvorak or Esperanto are;
Russian, Urdu or us(rus) are not (how this is
measured).
Only keyboard layouts are switched. Input methods in fcitx5 (Pinyin, Mozc and the like) are left alone, and other programs are not kept from reading the keyboard.
- Terminals: password prompts of
sudo,ssh,read -s, and anything else that reads a password the waygetpassdoes. Any terminal emulator (tested in Ghostty and foot); tmux panes too. - Graphical applications: password fields that are marked for the input method, through an addon for fcitx5. Zen (Firefox-based) and Chromium do this; Qt applications too, with fcitx5-qt 5.1.16 or newer (#7). Electron password managers are not checked yet (#8).
The scope is deliberately narrow: one person at a real keyboard in a Hyprland session. Virtual consoles, the boot and disk-unlock screens, remote machines and other compositors are out of scope.
- Hyprland, with a Latin layout somewhere in
kb_layout(us,ru,ru,usandus,de,ruall work). Layouts that fcitx5 switches (keyboard-ruin its input method list) are not handled; keep them inkb_layout. - For password fields in graphical applications: fcitx5 running as the input method.
- systemd, for the user service. To build: Rust with
cargo1.89 or newer,g++with C++20 and fcitx5's development files for the addon,make, andtmuxfor the tests. No other libraries.
curl -LO https://github.com/yesm1ke/password-layout/releases/latest/download/password-layout-x86_64.pkg.tar.zst
sudo pacman -U password-layout-x86_64.pkg.tar.zst
Give pacman the downloaded file, not the URL: pacman caches downloads by file name and would reinstall the old one. To update, run the same two commands, then restart the service and fcitx5: running copies keep the old version. To check the package before installing, see SECURITY.md. The package is not in the AUR yet (#11).
git clone https://github.com/yesm1ke/password-layout
cd password-layout
make test # the tests
make install-user # for the current user, no root: ~/.local, service enabled
make uninstall-user
System-wide, as a package does: make && sudo make PREFIX=/usr install.
Installing enables nothing, as usual on Arch. Each user turns the service on
and restarts fcitx5 so it loads the addon (make install-user does the first
part itself):
systemctl --user enable --now password-layout-tty
password-layout doctor # says what is still missing
To turn it off: systemctl --user disable --now password-layout-tty. The
fcitx5 addon is unloaded when fcitx5 restarts after the package is removed.
For a password prompt the project does not recognise by itself, a script can hold Latin for as long as it needs:
password-layout enter my-prompt # Latin now, unless a Latin layout is active
trap 'password-layout leave my-prompt' EXIT # always give it back
systemd-ask-password "Disk password:" # anything that asks for a secret
enter switches at once, wherever focus is. The layout from before comes back
after the last holder leaves; a holder never given back keeps Latin until the
end of the session, hence the trap. Names are lowercase letters, digits and
-, up to 32 characters. Useful for prompts that draw asterisks
(#9).
Start with password-layout doctor: it checks everything the project depends
on, says what is wrong and what to do, and exits with 1 when something is
broken. For more detail:
password-layout status: current layout, who holds Latin (ttyfor terminals,imfor graphical applications), which terminals are at a prompt.- Every switch is logged:
journalctl --user -u password-layout-ttyfor terminals, the fcitx5 log for applications (journalctl --user -u omarchy-fcitx5on Omarchy). - What fcitx5 knows about the focused field:
tools/fcitx-watchfrom a checkout. The addon's own debug log:busctl --user call org.fcitx.Fcitx5 /controller org.fcitx.Fcitx.Controller1 SetLogRule s passwordlayout=5.
A terminal does not say it shows a password prompt, but its pseudo-terminal's mode does: echo off while line input is on. The service wakes on terminal output and switches only if the prompt belongs to the focused window (tmux panes included). Graphical applications mark password fields for the input method, and the fcitx5 addon follows that mark. Details: How it works.
- A prompt in a background Ghostty tab or window counts as focused while any Ghostty window has focus (#43).
- Prompts that draw their own asterisks (
systemd-ask-password,sudowithpwfeedback) (#9). - Prompts of programs run under
sudo, such assudo ssh …or a shell fromsudo -i(#10). - Silent prompts: echo off with no output around it (#6).
- Multiplexers other than tmux (zellij, screen), and
sudoon a remote machine insidessh. - Programs that keep a terminal in "echo off, line input on" for their own reasons, such as an Emacs shell buffer, look like a prompt.
All of them: label limitation.
About 0.5 MB of its own memory and no timers: while terminals are quiet it only wakes for a moment when Hyprland reports something (a window title changes, focus moves). Roughly 0.05% of one core while a terminal prints continuously (measurements).
Issues, wiki, CHANGELOG.md, CONTRIBUTING.md. License: MIT.
