[SOLVED] "Oh no something has gone wrong" after editing keyboard layout and restarting X

TLDR: Attempted to customise a keyboard layout using XKB, restarted and am now getting a white “Oh no something has gone wrong” screen on startup

I recently began using the “Programmer’s Dvorak” keyboard layout, as selected from gnome-settings’ “Region and Language” tab. However, I wanted to edit the key between LShift and Z (in qwerty terms) to be a backslash. I googled around to try and figure out how to do this, and got to Custom keyboard layout definitions - Community Help Wiki. Following its guidance, I went to /usr/share/X11/xkb/symbols/ and used sudo nano to edit the file entitled us. Going to the definiton for Programmer’s Dvorak, I added the line (verbatim)

key <LSGT> { [ backslash,       bar                                         ] };

I am almost certain that I changed nothing else in the file.
I then wanted to restart X in order to see if this had worked. Following the advice of Ubuntu – How to restart X Window Server from command line – iTecTec (I realise that this and the last post are Ubuntu-related, but I thought that they would apply just as well to Manjaro), I ran the command

sudo systemctl restart display-manager

At this point, the screen went black for 15 seconds or so. Instead of returning me to the login screen for X, however, it brought up the “Oh no something has gone wrong” screen. At this point, I force-shutdown with the power button and restarted. I booted into Manjaro again and found the same screen.
This time I figured I ought to try to log in to TTY, so I tried CTRL-ALT-F1 through F6 and nothing happened. It seemed that the keyboard was completely unresponsive (I also think this because pressing CAPSLOCK and NUMLOCK do not turn on the LED indicator lights as they ought to. Also note that the keyboard definitely works in grub, so this is not a hardware issue.)
I tried rebooting again and strangely found myself stuck on the motherboard screen this time. I couldn’t boot even into grub, either by waiting or by pressing F12. At this point I took the machine apart and removed both the RAM and the CMOS battery, before replacing them. This worked (allowed me to get back to grub), but I was still stuck on the “Oh no” screen when trying to boot Manjaro. I also tried the fallback image to the same result.
As far as my own attempts to troubleshoot this have gone, I’ve looked around at other instances of this problem and they are typically caused by faulty graphics drivers or interrupted updates. I haven’t found anyone who encountered the problem in the same context as me (by which I mean that this seems to clearly be a problem not with the graphics but with Xorg, since that is the only thing I changed before this happened.)
manjaro-chrooting in from a live flash drive, I have checked the logs at /var/log/ and all that seems relevant is the following excerpt from Xorg.0.log:

[    51.361] (II) event1  - Power Button: is tagged by udev as: Keyboard
[    51.361] (II) event1  - Power Button: device is a keyboard
[    51.361] (II) event1  - Power Button: device removed
[    51.361] (**) Option "config_info" "udev:/sys/devices/LNXSYSTM:00/LNXPWRBN:00/input/input1/event1"
[    51.361] (II) XINPUT: Adding extended input device "Power Button" (type: KEYBOARD, id 6)
[    51.361] (**) Option "xkb_layout" "us,gb"
[    51.362] (**) Option "xkb_variant" "dvp,"
[    51.384] (EE) Error loading keymap /tmp/server-0.xkm
[    51.384] (EE) XKB: Failed to load keymap. Loading default keymap instead.

This is the only error line I could see (although it occurs multiple times in the log) and the fact that it is keymap-related makes it seem very likely that my tinkering with XKB is at least involved in this issue.
I have also tried a system update, but there was nothing to do.
Thanks if you read this far.

Note that one possible solution to this might be to reinstall gnome. If that is worth trying, can anybody tell me how to actually do that? A simple sudo pacman -R gnome-shell produces a litany of errors complaining about dependencies. How could I properly remove and reinstall gnome, and is this likely to save me?

key <LSGT> { [ backslash, bar ] };

that (yours) is the unaltered, original content of that file - it’s the same here on my system and I certainly didn’t change it.
You didn’t change anything there, is seems.
You could restore it - in case you altered something else in it - from the pacman package cache in:

… I don’t know which package contains it - but pacman can find out with the right command, which I also can’t reproduce off the top of my head

I am almost certain that I changed nothing else in the file.

If you did your changes via commandline, the history file (bash_history) might give you some clues as to what you did.
If your shell is zsh it’s likely similar, but I don’t know where that file is.
If you did your changes via GUI I know of no way to retrace your steps.

with GUI filemanagers, or with terminal apps like “ranger”, I always loose my way …
I much prefer the ancient two pane design that “mc” gives.
all the functions one could want are integrated
one can navigate quickly using the arrow keys and always have the two sides present
just a tip/hint and may be worth a try

That line certainly exists somewhere within the us file, but it was absent from the Programmer Dvorak layout, which is around line 550 of the file.

yes, you are right, that line occurs multiple times in that file
but not anywhere around 550
the closest in mine is:
line 681
and before that
line 197

… maybe restore the file from original package in pacman cache? :wink:

Exactly - I added that line around line 550 in order to change one of the keys in the Programmer Dvorak configuration, as outlined in the first link in the post.
It is possible that restoring the file would solve my problem, so I will try that, but I suspect it was more likely due to improperly restarting Xorg or something.

… is there such a thing as improperly restarting xorg?
which could damage things …

maybe more helpful:
pacman -Qo /usr/share/X11/xkb/symbols/us
the file is in the package “xkeyboard-config

reinstalling that will restore things changed in there …

Gnome, by default, uses wayland - but you probably changed that
I always ended up doing that … before I ditched it for good

By reinstalling, do you mean uninstalling the entire package and installing it again? If so, that creates the same dependency hell that trying to remove gnome-shell does:

pacman -R xkeyboard-config

checking dependencies...
error: failed to prepare transaction (could not satisfy dependencies)
:: removing xkeyboard-config breaks dependency 'xkeyboard-config' required by gnome-desktop
:: removing xkeyboard-config breaks dependency 'xkeyboard-config' required by libxkbcommon
:: removing xkeyboard-config breaks dependency 'xkeyboard-config' required by libxklavier
:: removing xkeyboard-config breaks dependency 'xkeyboard-config' required by xorg-server-common

Is there a different way to do this?

just reinstall it - don’t know whether you’ll have to force it
probably not
no need to remove it - that would take a lot of things down with it

pacman -S xkeyboard-config
should be all that is needed
it will overwrite any changed files (contained in it)
The same would have happened anyway with any update to that package.
User specific config changes should not be done to system files - they will always be overwritten on updates.

Well. That actually worked. I feel a bit dumb now. Thank you!

Since I’m not sure whether it was the process of editing the file or a mistake when doing so that caused the error, I’m not inclined to try it again.

I’m very glad it did.
It could have been worse - if you had to go try to retrace others of your steps and no way to do that.
… good memory :wink:

but you know how to fix it now :wink:
maybe that guide you used wasn’t … a good one
always make a backup of the file you are about to edit
or know how to otherwise easily restore it

If I where you - I would try again. :wink:

My greatest skill when it comes to resolving technical difficulties is giving the most complete information I can. You can’t help me if I don’t know what I did.

right on!
information is key!

Technically there is no need to redo it, because of some weird behaviour of X’s keyboard handling. I have two keyboard layouts selected in gnome-settings: English (UK) and English (Programmer’s Dvorak), so I can switch between them with a hotkey. Oddly, switching the order in which these two layouts appear seems to create different results.
For example the key in question is \ when English (UK) is first in the list, even when I have Programmer’s Dvorak active. If Programmer’s Dvorak is first in the list, that key will be <. I don’t really know why it does this, and I didn’t want to rely on such strange behaviour - that’s why I tried to change it so that I could have Programmer’s Dvorak first but still have that key be \ .
Another example is that I have the application guake-terminal installed, and the hotkeys configured in that application’s preferences always apply to the first layout in the list - so if I have a hotkey set to CTRL-Q then that means I have to hit the location of Q in QWERTY, regardless of which keyboard layout is active.
Sorry for the rant but I can’t help but feel that the implementation is a bit wonky here :laughing:

I never felt the need or dared try a different keyboard layout.
I’m as bad as they come with the standard keyboard, never learned to type without looking …
and on a laptop - well, there is your layout that you’ll have to use …

Sorry for the rant but I can’t help but feel that the implementation is a bit wonky here

no need to be sorry - I really liked Gnome and wanted to use it
but as it progressed - and if you are not satisfied with how it looks and works by default - and thus want or need to adapt it - it has been nothing but a pita

xfce it is now for me - but that may also be in need for a change in the future

Yeah that’s fair enough. I know there are also a load of issues with gnome extensions, although this is supposedly being worked on (The GNOME Extensions Rebooted Initiative – Sri Ramkrishna), so I wouldn’t blame someone who cares about customisability to use a different DM. That being said, I’m not really sure whether keyboard layouts are handled on the DM (Gnome) or WM (X) level. I suspect that it might be both in some confusing way, which might be where the weird behaviour comes from.

DM (Gnome) or WM (X)

that is not an accurate distinction …
the DM is what logs you in - the WM (and whether it is running under xorg or wayland) is what affects how things work in your environment.
What the desktop runs on depends on and is a choice between wayland (the Gnome default) or xorg (the alternative that you’ll actively have to choose)
Some of the consequences of that choice affect how things work and what will work as expected vs what would need to be done differently.
Handling of keyboard layouts may be affected - I don’t know.

I see… That’s helpful to know :>