4

Using Tweaks to set keyboard layout works immediately. After reboot, although the settings I made are kept, Tweaks is ignored.

I find some solutions on the Internet, but all are related to older ubuntu versions(eg. soltion for older ubuntu versions). I can't find these files mentioned in these solutions on ubuntu 18.04.

[UPDATE] The changes I made are in Keyboard & Mouse > Additional Layout Options > Alt/Win key behavior and Caps Lock behavior shown in the screenshot.

screenshot of options I chosen

The ls -al ~/.config/dconf command outputs:

total 24
drwx------  2 wen wen  4096 Aug 20 19:15 .
drwx------ 27 wen wen  4096 Aug 20 15:20 ..
-rw-r--r--  1 wen wen 13758 Aug 20 19:15 user

I tried cd ~/.config/dconf && mv user user.bak and reboot. Then the ls -al ~/.config/dconf command outputs:

total 32
drwx------  2 wen wen  4096 Oct 20 21:41 .
drwx------ 27 wen wen  4096 Aug 20 15:20 ..
-rw-r--r--  1 wen wen  4958 Oct 20 21:41 user
-rw-r--r--  1 wen wen 14064 Oct 20 21:25 user.bak

A new ~/.config/dconf/user file was created. It seems all settings were reset to default. So I used Tweaks to set again and it dose change the ~/.config/dconf/user file.

-rw-r--r--  1 wen wen  5084 Oct 20 21:47 user

Reboot again, the ls -al ~/.config/dconf command outputs:

total 32
drwx------  2 wen wen  4096 Oct 20 21:57 .
drwx------ 27 wen wen  4096 Aug 20 15:20 ..
-rw-r--r--  1 wen wen  5084 Oct 20 21:57 user
-rw-r--r--  1 wen wen 14064 Oct 20 21:25 user.bak

The gsettings get org.gnome.desktop.input-sources xkb-options command outputs:

['altwin:swap_alt_win', 'caps:ctrl_modifier']

The cat /etc/default/keyboard command outputs:

# KEYBOARD CONFIGURATION FILE

# Consult the keyboard(5) manual page.

XKBMODEL="pc105"
XKBLAYOUT="us"
XKBVARIANT=""
XKBOPTIONS=""

BACKSPACE="guess"
Gunnar Hjalmarsson
  • 32,938
  • 3
  • 63
  • 94
Hovin
  • 43
  • 5
  • What keyboard layout in Tweaks are you amending? – graham Oct 20 '19 at 07:39
  • I selected `Alt is swapped with Win` and `Caps Lock is also a Ctrl` options. @Graham – Hovin Oct 20 '19 at 08:32
  • 1
    Presumably under Additional Layout Options→Alt/Win key behaviour. Please edit your question to show a graphic of how you have set these options. – graham Oct 20 '19 at 08:44
  • 1
    Yes, it is under `Additional Layout Options`. I have updated my question.@Graham – Hovin Oct 20 '19 at 09:35
  • Have you tried just changing just one option to see if that persists? Maybe the two together are mutually exclusive. – graham Oct 20 '19 at 10:45
  • I tried, but it still dosen't work after reboot.@Graham – Hovin Oct 20 '19 at 11:24
  • Sure. I have added it into my qusetion.@GunnarHjalmarsson – Hovin Oct 20 '19 at 11:25
  • I tried this. The settings still doesn't work.@GunnarHjalmarsson – Hovin Oct 20 '19 at 13:29
  • I have edited my question. After I set keyboard through `Tweaks`, I checked the `~/.config/dconf/user` file and it indeed was changed. Then I rebooted and checked the `~/.config/dconf/user` file again. It's time stamp was changed. Is it possible that something overwirte this file when I reboot?@GunnarHjalmarsson – Hovin Oct 20 '19 at 14:19
  • I have updated my question. I also have checked the two commands' ouput after reboot. The output keeps the same but my settings dosen't work. – Hovin Oct 21 '19 at 03:05
  • @Wen: That's a mystery. `xkb-options` are set as expected, they are not overridden at reboot, but still not effective? I'm lost. – Gunnar Hjalmarsson Oct 21 '19 at 12:20
  • It's still not effective. After reboot, the keyboard doesn't work as expected but the `Tweaks` shows as expected. If for example I cancel the `Alt is swapped with Win` option and choose it again, the keyboard will work as expected. It's pretty annoying. Anyway, thank you.@GunnarHjalmarsson – Hovin Oct 21 '19 at 15:23

1 Answers1

2

As a workaround you may want to try to edit the /etc/default/keyboard file and replace

XKBOPTIONS=""

with

XKBOPTIONS="altwin:swap_alt_win,caps:ctrl_modifier"
Gunnar Hjalmarsson
  • 32,938
  • 3
  • 63
  • 94
  • It works, thank you. BTW, are `/etc/default/keyboard` and `xkb-options` two different configration files? Is it possible that `xkb-options` is loaded first and then `/etc/default/keyboard` which has `XKBOPTIONS=""` leading to the final settings as default? – Hovin Oct 22 '19 at 01:50
  • @Wen: It ought to be the other way around. `/etc/default/keyboard` contains system wide default settings affecting all users, while the dconf `xkb-options` key is user specific, and should override `/etc/default/keyboard`. So there is something with the configuration of your system which we haven't figured out; hence I consider it to be a workaround. – Gunnar Hjalmarsson Oct 22 '19 at 04:51
  • Solved for me, after Tweaks mysteriously started reverting this – Yuri Ghensev Nov 03 '20 at 14:43