Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed keyboard layout does not survive reboot #4

Closed
beta-tester opened this issue Oct 4, 2015 · 43 comments
Closed

changed keyboard layout does not survive reboot #4

beta-tester opened this issue Oct 4, 2015 · 43 comments

Comments

@beta-tester
Copy link

according to https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=122060

if i install Raspbian Jessie and use the "Raspberry Pi Configuration" and change the keyboard layout from en-UK to de-DE, the keyboard layout is changed only temporary.
as soon i reboot the Raspberry Pi, all keyboard layout changes gone lost, i made with "Raspberry Pi Configuration"

i have install Raspbian Jessie via NOOBS v1.4.2 and via NOOBS lite v1.4 on a RPi1B and RPi2B.

if i change in NOOBS the keyboard layout, and install Raspbian, then this changed keyboard layout takes affect in the OS - that works and survive reboots
(it is a one-time change via /boot/os_config.json and init.d).
if i change the keyboard layout via raspi-config afterwards the installation of Raspbian, that works as well and survive reboots.
but if i change the keyboard layout via "Raspberry Pi Configuration" the keyboard layout is gone and is back to what ever it was bafore i used "Raspberry Pi Configuration".

@spl237
Copy link
Contributor

spl237 commented Oct 4, 2015

The problem is that for some reason, the command to reload the saved keyboard when X starts up does not seem to be automatically running in every case.

There is a fix for this which involves running the keyboard settings reload in the general autostart settings rather than those in the session manager; this has been tested and found to work, and will be pushed in the next update.

@spl237
Copy link
Contributor

spl237 commented Oct 4, 2015

If you want to try the fix, create the file /home/pi/.config/autostart/lxkeymap.desktop, with the following content:

[Desktop Entry]
Type=Application
Name=lxkeymap
Comment=Load international keyboard settings
NoDisplay=true
Exec=sh /home/pi/.config/lxsession/LXDE-pi/autokey.sh
NotShowIn=GNOME;KDE;XFCE;

It would be great if you could confirm whether or not that works on your system - many thanks.

@beta-tester
Copy link
Author

yes, that made the change...

  1. i made a virgin Raspbian Jessie installation via NOOBS v1.4.2.
  2. i tried to change the keyboard layout from en-UK to de-DE, via Raspberry Pi Configuration.
  3. rebooted RPi, and the keyboard layout was back to en-UK.
  4. i tried to change the keyboard layout from en-UK to de-DE, via Raspberry Pi Configuration.
  5. rebooted RPi, and the keyboard layout was back to en-UK.
  6. i tried to change the keyboard layout from en-UK to de-DE, via Raspberry Pi Configuration.
  7. rebooted RPi, and the keyboard layout was back to en-UK.
  8. logged in remotely via SSH and first created a autostart folder:
    mkdir -p ~/.config/autostart/
  9. created the file with the content you showed:
    nano ~/.config/autostart/lxkeymap.desktop
    ...
  10. rebooted RPi, and the keyboard layout was now on de-DE as i changed at step 6.
  11. rebooted RPi, and the keyboard layout was still on de-DE.

so it works.
thanks for the solution, hope it will get be updated soon.

@spl237
Copy link
Contributor

spl237 commented Oct 4, 2015

Thanks for testing; we'll include it in the next release.

@beta-tester
Copy link
Author

a recent update with "sudo apt-get -y upgrade" broke the de-DE key layout settings again, now even with the workaround you showed me before (lxkeymap.desktop).

@beta-tester
Copy link
Author

maybe not the update is now the issue...
if i unplug and plug again my usb-keyboard, the settings switch back to en-UK immediately.
any idea, how to fix that, to have permanent the de-DE settings, that survive a reboot RPi and unplug/plug keyboard?

@wardjk
Copy link

wardjk commented Nov 3, 2015

I have the same problem as beta-tester. In my specific case, I use a KVM switch to connect to the RPi. The selected language doesn't matter. Upon reconnecting the keyboard to the RPi, keyboard layout setting goes back to "United Kingdom - English (UK)".

@beta-tester
Copy link
Author

i opened a new issue for the unplug/plug issue.

@ilmaisin
Copy link

spl237, what do you mean by "next release"? Does it mean that this will be fixed in Raspbian Stretch that will be released in about two years?

You know, this is not an advanced feature, but a basic feature that should no question work without a slightest issue.

@spl237
Copy link
Contributor

spl237 commented Nov 22, 2015

We make several releases of Raspbian each year. The fix for this will be in the next one. If you can't wait that long, then it is already in apt and can be downloaded from there using apt-get upgrade, or you can simply apply the fix described in my posting above.

If none of that is acceptable to you, then given the educational aims of the Raspberry Pi project and the free and open-source nature of Raspbian, why not try contributing to the community by fixing it yourself?

@ilmaisin
Copy link

We make several releases of Raspbian each year. The fix for this will be in the next one. If you can't wait that long, then it is already in apt and can be downloaded from there using apt-get upgrade, or you can simply apply the fix described in my posting above.

Well, I have already done apt-get upgrade, but the misbehaviour still continues. The keyboard layout set from raspi-config seems to persist reboots, but the one set from lxde settings per-user basis does not. Does Raspbian's X11 somehow use the console's keyboard layout by default, or how does it work?

If none of that is acceptable to you, then given the educational aims of the Raspberry Pi project and the free and open-source nature of Raspbian, why not try contributing to the community by fixing it yourself?

Unfortunately I find your answer lacking in internal consistency. The fix should be already committed, but on the other hand I should become a programmer and submit a fix for it? I'm sorry but now I don't understand.

@spl237
Copy link
Contributor

spl237 commented Nov 22, 2015

You say "The keyboard layout set from raspi-config seems to persist reboots, but the one set from lxde settings per-user basis does not."

What exactly do you mean by "the one set from lxde settings per-user basis"? Are you referring to the keyboard setting dialog accessed from the Raspberry Pi Configuration dialog (whose setting does persist across reboots if you have the bug fix referred to above) or something else? Settings made in any fashion other than through the keyboard settings dialog accessed from Raspberry Pi Configuration or from the Mouse and Keyboard Settings application are not supported.

Does your /home/pi/.config/autostart/ directory contain an lxkeymap.desktop file? Or is there one in /etc/xdg/autostart? If not, then you haven't upgraded correctly from apt - if there is, then a keyboard setting made in the Raspberry Pi Configuration application should be persisting over a reboot - this has been extensively tested and is known to work.

@ilmaisin
Copy link

Now it started to function. I had to run apt-get upgrade multiple times for some reason. I used the Mouse and Keyboard Settings from the menu.

@huebe
Copy link

huebe commented Nov 28, 2015

Just running apt-get upgrade didn't work on my pi, but according to the output the raspberrypi-ui-mods package got held back. Running apt-get dist-upgrade fixed it.

@spl237 spl237 closed this as completed Jan 5, 2016
@AlexanderSavelyev
Copy link

I just found the same issue with raspbian 2016-02-09. Running apt-get upgrade did not help me. But after some investigation the file /home/pi/.config/lxkeymap.cfg was found. This file caused the issue with changing keyboard layout after reboot. I removed lxkeymap.cfg (back-up first) and everything started to work.

@Vaulg
Copy link

Vaulg commented Feb 25, 2016

I had the same problem and running apt-get dist-upgrade fixed it.

@fabiovix
Copy link

fabiovix commented Apr 2, 2016

spl237,

Your solution worked perfectly here....tested with Brazilian layout and a Raspberry Pi 2 B running Raspbian Jessie. Thanks !

@deepakkapoor624
Copy link

I have followed your solution of writing lxkeymap.desktop file in Raspberypi3 but it didnt worked.

@fabiovix
Copy link

Hi everyone,

An update: in the new version of Raspbian, this issue seems to be fixed without the need for scripts. I've tested the 2016-03-18-raspbian-jessie.img with success available in:

https://www.raspberrypi.org/downloads/raspbian

@ShopmoFrank
Copy link

Hey there,

It's 2017, I am on a Raspberry Pi 3B and just installed a virgin Raspian Jessie with Pixel (Release 2017-01-11) and am still facing the issue. I did all updates and upgrades.

A shutdown followed by a regular start keeps the keyboard settings at de_DE.
A reboot dismisses the changes and sets the keyboard back to en_EN.
Setting up the file lxkeymap.desktop (followed instructions meticulously) didn't help.

I am using a bluetooth keyboard. It re-connects automatically after reboot. Only the language settings are being changed back to English.

Any other ideas? What I could do?

Thanks very much
Frank

@commonhatchetfish
Copy link

Same issues as Frank, though I'll add that my BT kb is being reset to UK QWERTY from US Dvorak not just on reboot, but every time it powersaves and reconnects, no pi reboot needed.

@spl237
Copy link
Contributor

spl237 commented Feb 17, 2017

OK, looks as if there may be an issue with how Bluetooth keyboards interact with the driver - I'll have a look when I get a chance.

@commonhatchetfish
Copy link

Quick update: since posting yesterday I've installed RetroPi (via the installer script for raspbian, not a drive image) and if set using retropi's config tool, the setting sticks through reboots and k.b. powersaves. Little drastic as a workaround, but i figured it might be useful info while investigating.

@karlmortensen
Copy link

I can set my keyboard to US English 104 key via sudo raspi-config, but it did not survive reboots either. As far as I can tell, I have the latest-greatest. sudo apt-get dist-upgrade and sudo apt-get upgrade both claimed there were zero packages to install. uname -a shows "Linux raspberrypi 4.4.34-v7+ #930 SMP Wed Nov 23 15:20:41 GMT armv71 GNU/Linux". I have a LXinput-setup.desktop file in the place mentioned,

With a wired keyboard and a wireless mouse, I was having issues with it switching to a UK keyboard every reboot. For me, the thing that fixed it was editing the file /home/pi/.config/lxkeymap.cfg and removing the text "intl" from the "variant =" option. After that, it worked like a charm.

@spl237
Copy link
Contributor

spl237 commented Feb 24, 2017

I believe I have found the issue here. The keymap is loaded by a call to lxkeymap --autostart on boot, but the keymap seems to be lost as soon as a keyboard is disconnected; at initial boot, a Bluetooth keyboard is probably disconnected as it has not yet been woken from sleep, so no keymap loads.

I've modified the Bluetooth plugin for lxpanel (which manages all Bluetooth connections for the desktop) so that lxkeymap --autostart is run whenever a BT keyboard connects. In my testing here, this retains BT keyboard maps over a reboot and when a keyboard sleeps and is rewoken.

We'll push this change out into apt in the near future - if anyone wants it before then, feel free to check out and rebuild lxpanel from the raspberrypi-ui GitHub repo.

@panzhongxian
Copy link

After changing the layout, I typed ~ in terminal and it worked well. But if I changed window to Text Editor immediately and type ~, it was not ~ any more. Is this the same issue?

@foice
Copy link

foice commented Feb 11, 2018

still have this issue on stretch ... am I alone?

@Taxicletter
Copy link

Taxicletter commented Feb 17, 2018

No, I have the same problem! Every other setting in the Raspberry setting panel is remembered, but not the keyboard layout. I use Stretch from the Google AIYproject.

EDIT: after a reboot or 3 the problem solved itself. I already updated an upraded, but I guess updating and rebooting once more did the trick. Or maybe I have a non-recognised keyboard, I use different keyboards sometimes.

@peentoon
Copy link

Same here... fresh install of stretch and i noticed that keyboard layout selection is not loaded after reboot.
Neither rpi-upgrade nor apt-get update/upgrade helped.
Was the aforementioned fix ever integrated? Given almost one year of silence, and now 3 new reports in few days, should we think this is a new issue?

@spl237
Copy link
Contributor

spl237 commented Feb 23, 2018

I've just checked this on the current image - if you use the Keyboard Settings dialog (accessed from either the Localisation page on Raspberry Pi Configuration, or the Keyboard tab in Mouse and Keyboard Settings), the setting is saved over reboot and correctly reloaded.

The fixes above were all integrated; if this doesn't work on your image, I suspect you are either setting the keyboard language by some method other than the dialog mentioned above, or something in your startup is broken and no longer loading the keymap at startup. I am not surprised that this doesn't work in the AIY version of Stretch; that's a pretty hacked-about release of Raspbian with known problems.

@peentoon
Copy link

peentoon commented Feb 24, 2018

I have configured the keyboard layout via raspiconfig on a fresh install of raspbian stretch downloaded from the official website. hardware is a raspberry pi 3. this does look like a bug.

@spl237
Copy link
Contributor

spl237 commented Feb 24, 2018

raspi-config is not the correct way to configure the keyboard for the desktop - you need to use the Keyboard Settings dialog, as described above.

@peentoon
Copy link

Indeed, i could work this around by setting the layout via the graphical interface (Main menu > Preferences > Mouse and Keyboard Settings > Keyboard > Keyboard Layout...)

@peentoon
Copy link

But why raspi-config does not work?

@spl237
Copy link
Contributor

spl237 commented Feb 24, 2018

Probably because, like a lot of the code in raspi-config, this particular option is old and ought to be deprecated. raspi-config is only really provided for backward compatibility in the console environment, but it isn't actively maintained - the GUI tool does everything raspi-config does, and is the recommended method for configuration.

@foice
Copy link

foice commented Feb 24, 2018 via email

@spl237
Copy link
Contributor

spl237 commented Feb 24, 2018

In that case, something is broken in your image - this method has been repeatedly tested on the Stretch image and it definitely works. Try downloading the latest clean image and see if it works on there; if it does, some change you have made to your image is breaking it.

@foice
Copy link

foice commented Feb 24, 2018 via email

@crowmagnumb
Copy link

I have a brand new pure install of 2018-03-13-raspbian-stretch and if I set the keyboard to Dvorak in the GUI raspberry pi config it will only be remembered upon running the GUI again. i.e. after startx. I am booting this pi into the command line and there it is NOT Dvorak. Even if I start the GUI and then "Exit to command line" it reverts back to Qwerty.

@crowmagnumb
Copy link

SOLUTION: Had to edit my config file directly.

sudo nano /etc/default/keyboard

and change XKBLAYOUT=”gb” to read XKBLAYOUT=”dvorak”.

Upon reboot I'm now good to go.

@Problematician
Copy link

Problematician commented Mar 24, 2020

I noticed that it is still not working properly after so many updates, since the "Close" button at the "Keyboard Layout Handler" does not mean OK, SAVE AND CLOSE the window.

My solution was to add two Keyboard Layout Handler to the Taskbar. One of them was set up, so that "Keep System Layouts" was ticked, one was with "Do not Reset Existing Options". In the meantime the one with the "Do not Reset Existing Options" ticked had been filled up with the proper languages I wanted, the other one left as is. Windows closed with Alt + F4 instead of Close button. I also went to Preferences/Keyboard and Mouse menu and changed the Keyboard layout there, so the first and second icon changed, but when pressing the Ctrl + Shift + CapsLock only the second icon changed. That means the application works, so I hit the key combinations until the first icon showed some text EVDEV or something, then removed it from the task bar. In the same time I added a spacer after the Keyboard Layout Handler and closed it. The thing got saved and survived rebooting.

@golumb
Copy link

golumb commented Nov 21, 2020

My solution was to add two Keyboard Layout Handler to the Taskbar. ...

Thank you, Problematician, that trick worked (nothing else did).

I got buster:
~ $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
...

I suspect this has something to do with the fact that clicking "Close" in the "Keyboard Layout Handler" dialog, doesn't do anything. You have to click "x" in the top right corner.

@fluxrider
Copy link

The lxpanel plugin xkb seems to not save it's config correctly for us. I resorted to edit the config manually.

Edit ~/.config/lxpanel/LXDE-pi/panels/panel

Find the xkb plugin entry. Mine on rpi400/RaspberryPiOS looked like this:

Plugin {
  type=xkb
  Config {
    Model=pc105
    LayoutsList=us
    VariantsList=,
    ToggleOpt=grp:shift_caps_toggle
  }
}

Update it with whatever you want, for me I want display as text instead of flags, and two keyboard layout:

Plugin {
  type=xkb
  Config {
    DisplayType=1
    KeepSysLayouts=0
    Model=pc105
    LayoutsList=us,ca
    VariantsList=,multix
    ToggleOpt=grp:shift_caps_toggle
  }
}

I deduces the key/value from reading the code at https://github.com/lxde/lxpanel/tree/master/plugins/xkb.
The constructor of the plugin initializes from this config file (and I guess never saves back).
You can get a list of values from man xkeyboard-config or by using the troublesome 'Keyboard Layout Handler' UI.

@raspberrypi-ui raspberrypi-ui locked as resolved and limited conversation to collaborators Nov 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests