Ubuntu 12.04 desktop hang because of gnome-session

I’m running Ubuntu 12.04 and i’m using Gnome 3 instead of the default Unity. I like the Debian interface much more than Unity. Anyway, every once in a while, when i boot up my laptop and after i log in, everything hangs. In other words, the wallpaper loads up fine and the menu bar also but wherever i click or whatever i try to do, it does not work. I can easily recognize this by the network icon, which looks like my networks adapters are disabled.

I don’t know the exact reason for this but i found a simple workaround. Since i can’t access the terminal emulator i’ll just use the X terminals. These can be accessed by pressing CTRL+ALT+F1 (or all the Fs until F7).

CTRL+ALT+F1

After this you have to log in. I tried to kill the gnome-session process and apparently, this automatically restarts the session, bringing you back to the normal login screen. Since this happens more than once in a while, i decided that i need an alias to kill the process faster.

First, identify the process ID. In this case it’s 3110

ps -e | grep gnome-session

gnome-session-ss

Second, get the number on the command line, in a variable or such. The line below searches for the gnome-session process from the list of processes that are outputed by ps -e and prints the PID using awk.

ps -e | grep gnome-session | awk ‘{print $1}’

And lastly, killing the process and adding everything into an alias so we can easily get back to it.

alias gnomebug=”kill -9 $(ps -e | grep gnome-session | awk ‘{print $1}’)”

Now, everytime i get the bug i just open a X terminal and run the gnomebug command defined by the above alias. Altough this doesn’t fix the problem it’s a fast way to get over it. I’ll get back with an update if i find the real fix for this.