1

I'm trying to do something similar to what this user asked, storing my keyboard layout. My first thought was to use .bashrc, but I turned to .bash_profile after realizing that I only need it set once (and not for every bash I start), as also suggested in that answer. However, I've noticed that the keyboard layout resets at certain points, and I'm not sure how to debug this (is it being set at all? when is it reset exactly?). Here's what is in my .bash_profile:

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
  . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin

export PATH

setxkbmap -layout us -variant altgr-intl -option nodeadkeys

This sometimes works. I've noticed in particular that this fails when I remove my laptop from my docking station and switching to the laptop screen, instead of my monitors, because this also seems to cause the keyboard layout to be reset (to plain US English, i.e., without altgr-intl). I thought this might have something to do with it, so here's the script I use to change the configuration :

xrandr --output VIRTUAL1 --off --output DP3 --mode 2560x1440 --pos 0x0 --rotate normal --output DP2 --off --output DP1 --off --output HDMI3 --off --output HDMI2 --off --output HDMI1 --off --output LVDS1 --off --output VGA1 --off
xrandr --output VIRTUAL1 --off --output DP3 --off --output DP2 --off --output DP1 --off --output HDMI3 --off --output HDMI2 --off --output HDMI1 --off --output LVDS1 --mode 1366x768 --pos 0x0 --rotate normal --output VGA1 --off

I thought it might have something to do with the fact that I turn off all output devices, which might cause X to freak out. I'm running Fedora 22 with i3 as window manager.

1
  • 1
    setxkbmap is bound to the X session and it can have problems when you switch X sessions or basically "play around" with it. loadkeys might be of help here, since it is X-independant. (consult man pages) Commented Sep 4, 2015 at 7:27

1 Answer 1

1

As you are on fedora, you might like to try localectl from the ever-popular systemd suite to change the default locale, including keyboard:

The keyboard settings control the keyboard layout used on the text console and of the graphical UI before the user logs in, such as the display manager, as well as the default for users after login.

localectl set-x11-keymap layout [model [variant [options]]]

Set the system default keyboard mapping for X11. This takes a keyboard mapping name (such as "de" or "us"), and possibly a model, variant and options

It basically takes the same args as setxkbmap.

It actually edits /etc/X11/xorg.conf.d/00-keyboard.conf to set the global default for language and keyboard layout i.e. that used before login, and by default for a user.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .