Linux Session Customization
289 views
Many people have heard of “writing your own session manager” or wondered how to get a program to start up when you log on. In this article I’m going to teach you how to accomplish this, and tell you what I use.
I installed Linux Mint 4.0, which comes with GNOME installed and configured as default. I’d never used GNOME much in the past, so I’d installed this version on purpose to give it a try for a longer period of time. As I experimented and tweaked, I learned that GNOME is made up of several programs:
- gnome-panel
- This provides the bar containing the menus, and depending on your GNOME configuration in the same or other bars, the clock, system tray, task switcher, and viewport switcher.
- nautilus -n
- This provides the desktop, including the wallpaper, right click menu functionality, and display of icons and the ~/Desktop folder.
- gnome-wm
- This is GNOME’s WM, providing the bar and buttons around your windows, allowing you to change focus between them and drag them around.
- more…
- A few other programs, providing management of the system and configuration settings. We’ll cover these later.
KDE consists of a few programs as well, and the main ones are listed here:
- kicker
- This provides the bar containing the menus, clock, system tray, task switcher, and viewport switcher.
- kdesktop
- This provides the desktop, including the wallpaper, right click menu functionality, and display of icons and the ~/Desktop folder.
- It’s important to note that kdesktop will not launch without klauncher, which can only be launched by running kdeinit. kdeinit, despite it’s name, will not actually do anything in the frontend, so it’s OK to start it with your session when not using most KDE components.
- This provides the desktop, including the wallpaper, right click menu functionality, and display of icons and the ~/Desktop folder.
- kwin
- This is KDE’s WM, which is what creates the bar and buttons around your applications, and allows you to change focus and move them around.
- more…
- A few other programs, again we’ll cover these later.
There are a number of programs that can be mixed and matched with these, and I’ve looked at the following recently and in the past:
- GkrellM and GkrellM2
- This provides an extensive system monitor that is fairly compact for the amount of information it contains.
- Avant-Window-Navigator
- This is a really cool application, providing an OSX-like dock for Linux users. Many applications have been available to emulate the dock on Windows, but this is the first one I’ve seen on Linux.
- Note that applet support is largely broken and preliminary at this point. Some people have them work fine, but many (me for example) cannot get some applets to work regardless of presence of dependencies.
- This is a really cool application, providing an OSX-like dock for Linux users. Many applications have been available to emulate the dock on Windows, but this is the first one I’ve seen on Linux.
- Stalonetray
- This little program is simply a stand-alone system tray, hence the name. It’s terrible if launched raw, having window widgets, etc., so it’s important to look into the command line options when using this as your tray.
- Pypanel
- Pypanel is a stand-alone version of kicker or gnome-panel. It provides viewport switching, task switching, a clock, system tray, etc. However, what is important here is that it’s customizable. You can configure it to only display what you want, and how large, where, etc., to display it. This means that it can be your system tray, it can be your clock, or it can be any combination of these things.
- Compiz/Beryl
- This is the most amazing thing about Linux as far as graphics, in my opinion. This program is a WM, so it would replace with kwin or gnome-wm. This is “that program” that adds all of the crazy effects like windows with physics, shattering or burning as you close a window, motion blur, etc. - it’s impossible to list all of it’s possibilities and effects here. Compiz/Beryl are really the same program. Beryl is newer than Compiz, having evolved from it, but they both contain almost identical features and are both complex to install/configure.
…”but how do I make these programs launch together when I log in,” you’re probably asking. I was just getting to that. The best way to do this, in my experience/opinion, is with the xsession file. You can edit this file with the following command (assuming you want to use nano, if not simply replace it with vi, emacs, ed, or whatever you use):
nano ~/.Xsession
(Note that on some systems you should use .xinitrc, check your distribution’s documentation if this doesn’t work)
In this file, called your “session manager”, the programs to be launched at login are defined. My file looks like this:
#!/bin/bash
gnome-volume-manager &
gnome-power-manager &
gnome-settings-daemon &
compiz &
nautilus -n &
avant-window-navigator
- The first line of this file is a shell declaration, simply include it, or if you don’t use bash, change it to whatever shell you do use.
- “gnome-volume-manager” controls the mounting and management of devices, and is tied into Nautilus (so if you plan to use Nautilus, you should also run this).
- “gnome-power-manager” provides power management, allowing sleep, hibernation, etc..
- “gnome-settings-daemon” acts as the middleman between all of those “Preference” applications and the actual place where they effect changes. If you’re primarily using GNOME’s configuration apps, you should run this.
- Compiz. This is my WM, providing all of those pretty effects and letting me move my windows about.
- “nautilus -n” - this provides my desktop.
- “avant-window-navigator” - my dock (I don’t use any panels).
You’ll probably notice the “&” symbols after each line. Whether you did or not, it means to start this process in the background. Every line but the last must have this, allowing the session (which is actually a process) to start each program without stopping, until hitting the last one (in this case my dock). When it hits that last program, it will pause until that program stops, at which point it will end the session. It is common practice to assign this to your panel, but in my case, lacking a panel, I’ve put my dock last in the queue.
And here’s the result. Note the terminal that I was shaking up and down furiously to demonstrate the window physics from Compiz in a static shot, lol:

I’ve also got a version of my xsession that uses the KDE desktop:
#!/bin/bash
gnome-volume-manager &
gnome-power-manager &
gnome-settings-daemon &
compiz &
kdeinit &
kdesktop &
avant-window-navigator
Most of this is the same, with the “nautilus -n” line switched for “kdesktop”. However, take note that I inserted “kdeinit” as well, which is required for kdesktop to work properly. Also keep in mind the order of the items, as I ran kdeinit before kdesktop. If if did it the other way around, it most likely would not work properly.
It is common practice to have a panel, a WM, and a desktop, as well as various settings and backend programs (like the gnome- ones I use). The bare minimum you need is a WM and something to launch programs with. I could accomplish a very simple session with no effects and just a terminal to launch things with if my session manager was like this:
#!/bin/bash
gnome-wm &
gnome-terminal
I could then launch programs with the terminal (using “&” symbols to avoid keeping the terminal occupied), and when the terminal is closed, the session would end.
When you’ve changed your xsession file, the quickest way to see the changes is to hit “ctrl+alt+backspace”, which restarts X11/Xorg. You can then log back in and see the effects. If anything bad happens (such as no way to start programs or revert changes), don’t fret! Simply move to a console (ex. “ctrl+alt+f1″ for tty1) and make the appropriate changes. On the other hand, if this has scared you into not wanting to continue, or you’re frustrated, you can also delete the .Xsession file entirely, using the defaults and letting you get back in.
In Debian-based distributions, such as Ubuntu, Kubuntu, and Linux Mint (which I use), there’s a slightly odd way to install packages that may not be included in the main repository. Sometimes the directions are slightly different (and don’t work), or can be confusing, so I’m going to include my version here.
- Get to the webpage that distributes the program. You can always compile from source, but if there’s a package repository, copy the links they provide. (they will most likely look something like “deb http://domain.com/some-things/blah gutsy main”. The words on either end of the link are important - they instruct aptitude/apt-get on what exactly they’re pulling from.
- “sudo nano /etc/apt/sources.list”, of course substituting “nano” for whatever you use.
- Scroll to the bottom of the file and append the two links on their own lines.
- Run “apt-get update” (run “upgrade” as well if you haven’t in a while), this will get the lists of packages from the new repositories.
- Run “apt-get install package-name”, substituting what you’re installing for “package-name”. This should be provided on the website of the program, but if not you can try the program’s name.
That should be all that you need to know to customize your Linux desktop’s sessions to your heart’s content. If there is anything else you’d like to know, or if you have questions (or comments) about any of this, feel free to post a comment! I always enjoy feedback and take ideas from you as inspiration for edits or new articles.
Oh, and by the way, I heard of a few of these programs and ideas from Garoth, over at his blog “garoth.com”. You can find his post here.
Popularity: 8% [?]
Explore posts in the same categories: articles, linux, tweaking
March 9th, 2008 at 6:13 pm
Nice article. Thanks for the link.
March 9th, 2008 at 8:05 pm
Sorry for the doublepost, but thought to mention some few small nitpicks:
* It’s not so much Compiz/Beryl anymore since they merged to become Compiz Fusion
* No reason to sudo nano .Xsession considering you don’t need root permissions to edit the file… also, sudoers may not be configured correctly on everyone’s systems to allow for it. Furthermore, if nano creates the file, it’ll likely do so with root as the owner.
* .Xsession is actually called .xinitrc on some systems
But yeah, very well written
March 9th, 2008 at 8:16 pm
I realize Compiz and Beryl have merged but in my particular case the old compiz release was preinstalled, so I just used that. If they visit the Beryl link I provided I believe it is the same page as “Compiz Fusion”.
I made the change about that sudo, good catch. Also I forgot about .xinitrc, so thanks for reminding me. It’s been a while since I’ve dealt with anything but *buntu, heh.