Varyable’s Blog

March 18, 2009

Handling Xorg et al

Filed under: linux — varyable @ 7:14 am

This post is based on both my personal experience (which isn’t much as I have never waded into the source code of any of the programs we talk about) and this document. Though it would revolve around KDE, the concepts may be used with other DEs as well. The post BTW talks about various ways of *rescuing* a malfunctioning X/KDE session, and if it isn’t recoverable, how can one reboot one’s system with (hopefully) minimal loss of work.

Plasma Weirdities/Oddities

If plasma crashes, it would automatically restart itself (just like explorer.exe in Winblows). Sometimes however, the panel which is part of plasma disappears. In such a situation we have to restart the whole plasma desktop shell to get back our panel. plasma could be relaunched from krunner (alt+F2, krunner runs independently of plasma desktop shell as a standalone app). Additionally, one could switch to a vt (virtual terminal) using ctrl+alt+Fn (where n is 1,2…6) and use these commands:

DISPLAY=:0 plasma&

disown %1

Window Manager Crash

If you lose the title-bars and borders of all of your windows, that means your WM (e.g kwin) has crashed. We need to relaunch kwin to get back our borders, title bars etc, and be able to minimize, maximize or re-size our windows again. Krunner and plasma would automatically restart upon crash, kde devs are planning to add the same behaviour to kwin as well (it isn’t there yet as of KDE 4.2.1). Do keep in mind that alt+F2 (krunner) won’t work, so that you can’t issue a command from there. Also alt+tab won’t work so that you won’t be able to retract focus to a particular window (konsole, for instance). There are three ways, I can think of, in which we can relaunch kwin:

  • Add kwin as a new application using menu-editor. Use ‘kwin –replace’ (w/o quotes) as the command and assign it a shortcut key (e.g alt+z). Pressing alt+z would restart kwin for you. Alternatively, you can add this new application to the panel and launch it from there. Panel is part of plasma BTW, which is independent of kwin.
  • Switch to a vt and issue these commands:

DISPLAY=:0 kwin&

disown %1

  • As I mentioned earlier, you would have problems retracting focus back to your desired window. So even if you have konsole/yakuake open, typing into them may not work (due to loss of focus). Konsole lost focus because you were working in some other app while kwin crashed, and alt+tab won’t get you back to konsole. You may be able to launch konsole from kickoff/kmenu or from a launcher on the panel, but problems with focus may still be there. The following command would get you back your WM:

kwin&

KDE’s session manager is called ksmserver (which speaks XSMP, X Session Management Protocol). Its crash would bring down a whole kde session, which is irrecoverable obviously.

KDM’s Story

When you press ctrl+alt+backspace, you think that it restarted your Xserver, which isn’t true. ctrl+alt+backspace actually kills your Xserver. Moreover, If you don’t have any DM running (i.e you start an X session from console using startx or something) X will send TERM then KILL signals to all of its child processes (thus cleaning/reaping all of its children i.e the whole KDE session).

The illusion of the Xserver restarting upon ctrl+alt+backspace is because of the KDM relaunching it. If you do use a DM (e.g KDM), ctrl+alt+backspace doesn’t kill the DM, it kills the Xserver only. When the DM (which is still alive) knows about the Xserver’s demise, it relaunches it as it’s child process. Also, KDM re-spawns if it crashes or is killed, due to an entry in /etc/inittab file.

Restarting X

If relaunching your WM doesn’t work, then you need to restart X (you avoid rebooting your whole OS at least !!). X should respond to ctrl+alt+backspace in the first place, if it doesn’t then you should switch to a vt and do either:

killall -9 X

or

init 1

Then you can do ‘init 5′ or such to get back to your full X session. If all of this fails, then our last resort is of course a hardware reset.

ACPI assisted poweroff

Powerdevil (KDE4’s power manager) comes built-in with KDE 4.2.x based systems. It relies on KDE4’s infrastructure (Solid?…) for receiving & handling any ACPI events. I made it ignore any power-off (generated by slightly pressing the power button of the system) events by going to “System Settings” > “Advanced tab” > “Power Management”. Next what I did was to enable acpid to handle my power-off events and respond to them by gracefully shutting down the sytem. A more robust solution to not losing one’s important work is to use System Request facility, which yields the CPU to the user for any last-minute rescue operations.

No Comments Yet »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.