Autostart applications in Openbox 3.5

June 30, 2012

The way openbox-session autostarts applications changed in Openbox 3.5, the latest release. Openbox-session is the session manager for Openbox, which is launched when you run Openbox as a stand-alone window manager, not as the window manager within a desktop environment like Xfce or KDE that has their own session manager. In earlier versions, openbox-session would look for the autostart.sh (now also renamed to just autostart) file in ~/.config/openbox, or, if that file did not exist, the system wide autostart file located in /etc/xdg/openbox. That autostart file contains a list of applications or commands that are launched whenever Openbox through openbow-session.

When I upgraded to Openbox 3.5 I noticed that whenever I launched openbox-session, a few applications I use in Gnome, but never in Openbox, would be launched at login, and some applications that I have listed in my autostart file would be launched twice.

After a little digging–the documentation on the Openbox website has not been updated yet–I figured out what was happening. Openbox-session now also launches /usr/lib/openbox/openbox-autostart, which in its turn runs /usr/lib/openbox/openbox-xdg-autostart.

Now, what does /usr/lib/openbox/openbox-xdg-autostart do? This is an Openbox implementation of the Freedesktop standards when it comes to autostarting applications. Similar to what Gnome and Xfce do, it looks in /etc/xdg/autostart and ~/.config/autostart for .desktop files of applications and launches those. These .desktop files are simple text files that tell the session manager what to launch at login. If besides pure Openbox, you also use desktop environments, you’ll have some .desktop files in there. Some applications (like wicd or gnome-do) also automatically copy a .desktop file into this directory when you install them.

This new behaviour is a little confusing, as openbox-session also still launches Openbox’ own autostart file, which means that some applications, such as wicd, will launch twice if you still have them in your autostart file. How do we fix that? You could just comment out the final line of /usr/lib/openbox/openbox-autostart (the line that says /usr/lib/openbox/openbox-xdg-autostart “$@”), but that may seem to some too crude a fix. That file will also be overwritten when you upgrade Openbox, so you’ll have to re-edit this file when you reinstall Openbox.

A more elegant, but more cumbersome, solution is to work with these new standards, and edit the .desktop files. As you might have noticed, not all of the applications that have .desktop files in these directories will be launched when you run openbox-session, because you can specify that you want these applications only launched or autostarted in specific desktop environments. To find out which applications will launch automatically by this openbox-xdg-autostart script, you can run the following command:

/usr/lib/openbox/openbox-xdg-autostart –list | less

If an application is marked to be launched at login, you can easily disable that by editing the application’s .desktop file, and adding a line telling it to only launch this application in certain desktop environments. Here is an example, using wicd’s .desktop file in /etc/xdg/autostart. This is the wicd-tray.desktop file:

[Desktop Entry]
Categories=Application;Network;
Exec=wicd-gtk –tray
GenericName=Network Manager
Icon=wicd-gtk
Name=Wicd Network Manager Tray
Comment=Display network connection status in the system tray
Terminal=false
Type=Application
Version=1.0
X-GNOME-Autostart-enabled=true
X-KDE-autostart-after=panel

If we want this file to be only used in Xfce or Gnome, and not in Openbox (because we already have the application listed in our autostart file, for example, or just because you don’t want to use this in Openbox), you can add the following line at the bottom of that file:

OnlyShowIn=’ENVIRONMENT’

Replace ENVIRONMENT here by your preferred desktop environment. The options are GNOME, KDE, ROX, XFCE, and one called “Old” which is supposed to be for “Legacy systems”, whatever that means. I believe LXDE also works. (Run /usr/lib/openbox/openbox-xdg-autostart –help for more information). If you want it to be launched in more than one DE, you have to separate the environment names with a semicolon, as follows:

OnlyShowIn=’GNOME;KDE’

Add this line to the .desktop files you don’t want launched in Openbox, and all should be normal again.

About these ads

2 Responses to “Autostart applications in Openbox 3.5”

  1. TenorB said

    Hey…I am forever in your debt for the amazing openbox guide, I also love all your other stuff on your blog… :D
    I recently have noticed where my world would be without everyone on the web, and have recently taken it upon myself to give a donation to every life-saving free thing I’ve found!

    Anyways, thanks. And I would love to donate to you! Can you put up a paypal donation button?

    Thanks again,
    -Tenor Biel

  2. rm said

    In fedora its “/usr/libexec/openbox-autostart”
    Thanks for your superb guide to openbox! It sold openbox to me and now I’m hooked!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 81 other followers