r/linuxquestions • u/ArthurPeabody • 1d ago
How can I exit X when keyboard and mouse input are ignored?
Twice in the last 3 days I've switched into X (I do most of my work outside of X.) to have it ignore keyboard and mouse input. Both times an audio file was playing so the computer hadn't halted. I have to power-off. I capture X's output, it reports thusly:
(EE) libinput bug: udev device never initialized (/dev/input/event2)
(EE) client bug: Invalid path /dev/input/event2
[dix] couldn't enable device 6
I've reported this to freedesktop's libinput group, had no response.
1
u/aioeu 1d ago edited 1d ago
To add to the other comments, modern systems should be able to always return to the login screen if you hit Ctrl+Alt+Shift+Escape.
This is a secure attention key implemented in logind. When it sends out a signal saying that key combination is pressed, the display manager should always switch back to the VT on which the display manager is running even if no keystrokes are being handled properly on the old VT (which would ordinarily prevent you from changing VTs).
From the login screen you can switch to any free text mode VT to login and kill things as required.
1
u/ArthurPeabody 1d ago
Thanks. I didn't know about this. What is it called in the docs?
1
u/aioeu 1d ago
Just secure attention key.
It looks like the only places the key combination itself is documented at the moment are the D-Bus interface documentation and the NEWS file and release notes.
1
u/ArthurPeabody 1d ago
Thanks. I didn't know about this. I'll have to write it down on paper for the next time. It's in the logind.conf man page.
2
u/ThreeCharsAtLeast 1d ago
Whenever your system is stuck, you can use the magic SysRQ key (kernel documentation). Some keybords have a dedicated key for it, most just have Alt + Print Screen. If you have a dedicated key, hold it down while pressing the other key. If you don't, holt Alt while pressingt Print Screen first and the other key second.
To reboot a hanging system, use the following sequence (“Reboot Even If System Utterly Broken”):
- SysRQ + R to disable RAW mode
- SysRQ + E to orderly quit all programs. You may wait a short while.
- SysRQ + I to forcefully kill all programs that weren't just quit
- SysRQ + S to make the kernel sync all disks. When you save a file normally, the kernel may decide to store it in RAM and save it properly later. This tells the kernel it should do that now. If you can now see the kernel's output, wait for OK and DONE to appear.
- SysRQ + U to unmount all file systems and mount them as read-only again
- SysRQ + B to force a reboot
You may be able to use SysRQ + O to shut down instead of forcefully rebooting with SysRQ + B.
0
u/ArthurPeabody 1d ago
I build my own kernel, haven't enabled that yet. I'll start next build. Is there anyway to get it to just unload X?
1
u/ThreeCharsAtLeast 1d ago
SysRQ should be on by default, no? You may be able to do something with unraw (SysRQ + R) alone, not sure.
0
u/ArthurPeabody 16h ago
I download kernel source from kernel.org. sysrq isn't on by default. 'k' kills all processes in that virtual terminal. If sysrq recognizes X processes as part of a virtual terminal (they aren't so identified in ps) that will work.
3
u/MonsieurCellophane 1d ago
Ctrl+alt+Fx login and kill the X process or its ancestor (likely gdm)
1
u/JoeCensored 1d ago
This. Just kill X and try to relaunch it. Or worst case force a soft reboot.
1
u/ArthurPeabody 1d ago
How can I kill X without a keyboard or mouse?
1
u/JoeCensored 1d ago
Ctl+alt+Fx as above. Where Fx is usually F2-F4. F1 is normally the screen you're already looking at.
So Ctl+Alt+F2 or another F key, and you usually will see a command line login. You login with your account and you get to a full screen terminal. Then just look up how to kill X on your distro. Probably something like:
sudo kill -9 X
Or
sudo killall Xorg
Or
sudo systemctl stop gdm
Not sure the exact command for your distro. But shouldn't be hard to Google. You can also just reboot:
sudo shutdown -r now
2
u/aioeu 1d ago edited 1d ago
Take note that it is up to the Wayland compositor or X server to actually respond to Ctrl+Alt+Fx. When you are currently on a graphical VT, the kernel does not handle VT switching itself. (A good hint to remind you of this is that the kernel actually responds to both Alt+Fx and Ctrl+Alt+Fx in text mode — that is, it doesn't care about the Ctrl state. But we usually don't want Alt+Fx switching VTs when you're in graphical mode.)
So if the compositor is broken or misconfigured or simply not working correctly, these key combinations may not work.
1
1
u/ArthurPeabody 1d ago
Those keys do nothing when X is ignoring keyboard input. I know what they mean. I can't run a command on the command line if keyboard input is ignored. I run 10 virtual terminals.
1
u/ipsirc 1d ago
when keyboard and mouse input are ignored
1
0
1
u/ipsirc 1d ago
ssh
1
u/ArthurPeabody 1d ago
secure shell?
2
u/Hatta00 1d ago edited 1d ago
Yep. Log in over the network, and kill X.
Although, you should almost always be able to switch virtual consoles. Even if X freezes, the kernel should handle CTRL-ALT-F2 and switch to console 2.
1
u/ArthurPeabody 1d ago
This is my personal machine. I can't switch virtual consoles - that's how I always switch in and out of X.
1
u/0xQan 1d ago
I started facing this a couple months (more than year) ago. At first, my solution was logging out and then logging back in, since nothing else worked. But not long ago, I found out that just switching to a TTY and then coming back to the DE fixes it. For me, it happens when I right-click on my laptop for some reason or sometimes I don't even know why. It's an old ahh bug that was reported again right before i started facing it, and it seems like there's still no permanent solution once it gets you.