Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I had a device running Ubuntu 12.04 LTS have its screen freeze. Generally I have simply jumped onto an available tty, i.e. Ctrl-Alt-F1 and executed the command /etc/init.d/lightdm restart or service lightdm restart. This however kills everything I have open. How do I avoid this?

share|improve this question
1  
You can't achieve this. It is lightdm which displays/manages windows in x system. –  Sachin Shekhar Mar 23 '13 at 1:46
    
This will also kill whatever you have open, but once upon a time ctrl-alt-backspace would restart X. That's easier than switching to a TTY, logging in, and asking X to restart itself. I'm not sure if it still works though. –  user162316 Mar 23 '13 at 3:46
    
@Douglas B. Staple - It doesn't work with Ubuntu 12.04 LTS. Not sure whether it still works with other distributions or whether this is specific to Unity. –  PeanutsMonkey Mar 23 '13 at 7:11
    
There may be some way to replace the window manager while running. (It's possible with the GNOME-Shell at least, or with the i3 window manager so there could be some way). –  FSMaxB Mar 24 '13 at 8:51
    
@FSMaxB - Could you please elaborate on how this can be achieved using the Gnome-Shell or i3 Window Manager? –  PeanutsMonkey Mar 26 '13 at 17:59
show 5 more comments

1 Answer

up vote 4 down vote accepted

Now I got it for Unity (I just replaced my GNOME shell with unity without logging out or closing windows):

  1. Go to tty1 [Ctrl]+[Alt]+[F1]
  2. Type in DISPLAY=:0 so that programs know on what port to find the X-Server
  3. export DISPLAY
  4. unity --replace or gnome-shell --replace (you can also replace GNOME-Shell by unity or Unity by the GNOME-Shell)

This only works if not the X-Server or GNOME is frozen but only Unity or the GNOME-Shell.

How it works: The communication between programs and the X-Server for displaying their UI is working over a network socket. This normally is at "localhost:0" short ":0". By setting the DISPLAY variable, the programs know where to find the X-Server to communicate with it, so programs are displayed on the X-Server on tty7 even if the program is running on tty1.

The content of windows is managed by the X-Server whereas the position and borders of the windows is managed by the window manager integrated in unity or the GNOM-shell so there is a way to replace only them without restarting the applications on the X-Server.

PS: I'm just describing what I understand it to be, so please edit and correct me if I'm wrong in some points.

EDIT: For the GNOME-Shell, there is another way to restart it. After changing to tty simply type in pkill -HUP gnome-shell, I don't know if there's something similar for Unity.

share|improve this answer
    
That worked like a miracle. In fact it saved me today. Thanks so much. I would be so grateful if you could elaborate what each of the steps do bar step 1. I don't quite understand what is happening under the hood. –  PeanutsMonkey Apr 1 '13 at 4:56
    
Thanks so much. That makes sense now. –  PeanutsMonkey Apr 2 '13 at 0:49
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.