Ever walked up to a computer and it appears that the computer is frozen? You cannot move the mouse, or, if you can move the mouse, you cannot click on a widget?
The first thing most people do is reboot.
Then it is fine. For a day. And you walk in, same thing. Screen Frozen. Reboot.
But in my case, I noticed that the server still seemed to be running (hosting web pages that responded, etc.).
The Clue
That was the first real hint. A truly frozen machine doesn’t keep serving web pages. If the kernel, the network stack and my services were all happy, the problem had to be higher up, in the desktop session.
The second hint was that the trouble always started after I’d been away from the machine. The setup is a desktop running XFCE, shared with another computer through a KVM switch. Every time I flipped the switch, the monitor was disconnected from one machine and connected to the other.
The Cause
To the operating system, switching a KVM looks like someone yanking the monitor cable out and plugging it back in. XFCE’s display manager (xfsettingsd) notices, and by default it does two things:
- It pops up a notification dialog about the display change.
- It tries to automatically apply a saved display profile to whatever it thinks is now connected.
When I came back to the machine, there was likely a dialog waiting for an answer, or a display layout that had been shuffled around while the monitor wasn’t there. Either way, the desktop looked dead. [Describe what you actually saw here: a dialog off-screen, a mouse stuck on one monitor, etc.]
The machine wasn’t frozen. It was waiting politely for me to deal with a question I couldn’t see.
The Investigation
I started by poking around XFCE’s settings with xfconf-query, the command line interface to XFCE’s configuration. After a couple of typos (display instead of displays, and a sudo that read root’s settings instead of mine), I listed the channels and the display properties:
xfconf-query -l
xfconf-query -c displays -l
cat ~/.config/xfce4/xfconf/xfce-perchannel-xml/displays.xmlThat last file is where XFCE stores its saved display layouts, and it showed the machinery that was reacting to my KVM switching.
The Fix
Two settings turned off the behavior:
xfconf-query -c displays -p /Notify -n -t bool -s false
xfconf-query -c displays -p /AutoEnableProfiles -n -t bool -s falseWhat they do:
/Notifystops the “display change detected” dialog from appearing./AutoEnableProfilesstops XFCE from automatically applying a saved display profile every time the monitor setup changes.
The -n -t bool part tells xfconf-query to create the property, since it doesn’t exist until you set it.
To verify:
xfconf-query -c displays -p /Notify
xfconf-query -c displays -p /AutoEnableProfilesBoth should print false. And if you ever want to undo it, remove the properties:
xfconf-query -c displays -p /Notify -r
xfconf-query -c displays -p /AutoEnableProfiles -rThe Result
[Add how long it’s been working: “No reboots in X days.”] I can now flip the KVM back and forth and the desktop is simply there when I return.
Lessons Learned
- “Frozen” isn’t always frozen. If the machine still answers on the network, check whether it’s just the desktop session before you reboot.
- A KVM switch is a hotplug event. Software that reacts to monitor changes will react to every switch.
- Reboots hide the cause. Rebooting made it “fine for a day” and taught me nothing.
- Keep your shell history. I wrote this post from
history | grep xfconf.