Using KWallet in Sway for Chrome

If you use KDE and Sway (or Hyprland) on the same machine with the same user (something I’m experimenting with), when you launch Chrome and log in with your user in KDE, and then switch to Sway, you’ll see that your account is marked as “Paused”: you have to log in again. The same holds the other way round.

That’s because in KDE, Chrome stores the credentials in KWallet, while Sway does not.

To fix this annoying problem, you have to ensure to run Chrome in Sway with the option “–password-store=kwallet6”.

To do that, you can either manually launch Chrome with that option or create the file “~/.local/share/applications/google-chrome.desktop” starting from the default file (in Arch it’s “/usr/share/applications/google-chrome.desktop”) and ensure the occurrences of the “Exec” line have that option, i.e.,

The desktop file in your home folder will have precedence over the default one.

However, while KDE automatically unlocks the KWallet when you log in, Sway does not. The first time you launch Chrome from a Sway session, you’re asked to open the wallet with your login password:

To let KWallet use your login credentials automatically (as KDE does, thanks to “/etc/xdg/autostart/pam_kwallet_init.desktop”), you need to tell Sway to start the corresponding PAM module.

The ArchWiki recommendation for “a window manager” setup is simply: run pam_kwallet_init from your WM/compositor startup.

Add this to ~/.config/sway/config (early in startup, before apps that need secrets):

That’s usually enough to avoid the post-login password prompt, provided PAM is already set up correctly (see the next section).

Important: pam_kwallet_init only works if PAM captured your password

pam_kwallet_init does not magically know your login password. It relies on the PAM module (pam_kwallet5.so) having captured it during login and made it available for the session handoff.

So:

  • If you start Sway via a display manager/session that already has pam_kwallet5.so in its PAM stack, then running /usr/lib/pam_kwallet_init In Sway, the wallet should unlock automatically.

  • If you start Sway via a path that doesn’t run the kwallet PAM module (common when starting from TTY, or via some greeters, depending on config), then pam_kwallet_init won’t have credentials to use, and you’ll still be prompted.

2 thoughts on “Using KWallet in Sway for Chrome

  1. Ali Ali

    I don’t usually use kwallet for chrome but this is still useful for other apps like brave that strictly needs kwallet

    Reply
    1. Lorenzo Bettini Post author

      Indeed I forgot to mention that the same approach can be used for other applications! 🙂

      Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.