Let’s break it down into two main parts:
1. Keyboard Layout Persistence (for the Xfce session):
The settings you configure in Xfce’s “Keyboard” settings (under the “Layout” tab) are generally per-user and should persist across restarts for that specific user. When you uncheck “Use system defaults” and add your desired layouts and a switching shortcut, Xfce saves these settings in your user’s configuration files (typically located in ~/.config/xfce4/xfconf/xfce-perchannel-xml/).
So, if a user logs in, sets their keyboard layout preferences, and then reboots, those preferences should be automatically applied when they log back into their Xfce session.
If they are NOT persisting, here are common reasons and solutions:
Use system defaults" is checked: Double-check that you’ve explicitly unchecked “Use system defaults” in Menu > Settings > Keyboard > Layout. If this is checked, Xfce will defer to the system-wide keyboard configuration, which might not be what the user set for their session.
Corrupted Xfce config files: Rarely, Xfce's configuration files can become corrupted. You can try resetting the keyboard layout configuration for your user by:
Log out of your Xfce session.
Switch to a TTY (Ctrl+Alt+F1 to F6).
Log in with your username and password.
Remove the keyboard layout configuration file:
rm ~/.config/xfce4/xfconf/xfce-perchannel-xml/keyboard-layout.xml
Go back to your graphical login (Ctrl+Alt+F7 or F1 if you changed TTY) and log in.
Reconfigure your keyboard layouts in Xfce settings.
Login Manager (Display Manager) settings: The keyboard layout at the login screen (before you even log into Xfce) is handled by your display manager (e.g., LightDM, GDM3). If the layout at the login screen isn’t what you expect, that’s a separate configuration.
For LightDM (common on Xfce): You can often set the keyboard layout for LightDM by editing a configuration file.
Create or edit /etc/lightdm/lightdm.conf.d/00-keyboard.conf (you might need sudo):
sudo nano /etc/lightdm/lightdm.conf.d/00-keyboard.conf
Add the following content, replacing us with your desired layout code (e.g., fr, de):
[SeatDefaults]
display-setup-script=/usr/bin/setxkbmap us
You can also specify variants and options:
[SeatDefaults]
display-setup-script=/usr/bin/setxkbmap us alt-intl
Save and exit, then reboot.
For GDM3 (if you installed it): GDM3 usually has a “Region & Language” setting that allows you to configure input sources for the login screen. You might need to have more than one user account to see the “Login Screen” button in the settings. Alternatively, you can use localectl:
sudo localectl set-x11-keymap LAYOUT [MODEL [VARIANT [OPTIONS]]]
For example:
sudo localectl set-x11-keymap us pc105 alt-intl grp:alt_shift_toggle
Then, verify with localectl status.
System-wide keyboard configuration: For the console (TTYs) and as a fallback for X, Debian uses /etc/default/keyboard. You can configure this with:
sudo dpkg-reconfigure keyboard-configuration`
This sets a system-wide default, but Xfce’s per-user settings will generally override it for the X session once you’re logged in.
2. Language Setting Persistence (for the UI language):
The UI language (menus, application text) is also generally a per-user setting and should persist.
Xfce Settings: In Xfce, the language is primarily determined by your user’s locale settings. You usually set this during installation or through a “Language Support” utility.
User’s ~/.profile or ~/.pam_environment: Your locale settings are typically defined by environment variables like LANG, LANGUAGE, and LC_ALL. These are often sourced from files like ~/.profile or /etc/default/locale (system-wide).
You can try creating or editing ~/.i18n in your home directory (if it doesn’t exist) and adding your desired language variables:
echo "export LANGUAGE=en_US.utf8" >> ~/.i18n
echo "export LANG=en_US.utf8" >> ~/.i18n
echo "export LC_ALL=en_US.utf8" >> ~/.i18n
(Replace en_US.utf8 with your desired locale, e.g., fr_FR.utf8).
Then, ensure that ~/.i18n is sourced by your Xfce session. A common place is ~/.config/xfce4/xinitrc. You might need to edit it:
nano ~/.config/xfce4/xinitrc
And add lines like this at the beginning (if not already present):
#!/bin/sh
if [ -f "$HOME/.i18n" ]; then
. "$HOME/.i18n"
fi
. /etc/xdg/xfce4/xinitrc
This ensures that your custom locale settings are loaded when your Xfce session starts.
System-wide Locale: For a system-wide change (affecting all users by default and the console), you can use dpkg-reconfigure locales:
sudo dpkg-reconfigure locales
This will give you a text-based interface to select and generate locales. After selecting, you’ll be asked to choose a default system locale. This will typically update /etc/default/locale.
In summary:
For per-user persistence after a restart:
Keyboard: Ensure "Use system defaults" is unchecked in Xfce's Keyboard settings and configure your layouts and shortcuts there.
Language: The Xfce system usually handles this per-user based on locale settings. If issues arise, check your ~/.i18n and ~/.config/xfce4/xinitrc files, or use dpkg-reconfigure locales for a system-wide default.
Remember to reboot after making system-wide changes (/etc/lightdm, /etc/default/keyboard, dpkg-reconfigure locales) to ensure they take full effect. For user-specific Xfce settings, logging out and back in should be sufficient.