Search Tillamook Rage
Google Custom Search


Autostart programs in Xfce the hardcore way

Ever want to autostart programs when Xfce loads? Don't want to, or can't, use the namby-pamby graphical version? Here's your guide.

This was performed using Xfce 4.4.1, as I haven't been able to test it on 4.4.2 yet, though it should work. Make sure to back anything up before making changes since any mistakes could cause damage to your system.

Autostart entries are the same as menu entries, simply .desktop files filled with information on the program. Now there are 2 ways to go about creating the files. You can either make the file from scratch or copy it from the applications menu. All autostart files are stored in the /etc/xdg/autostart directory.

1: Create the file from scratch

Let's say you want to start a program automatically. Generically, the file is named NAME.desktop and located in the /etc/xdg/autostart. Below is the basic layout of an autostart file for a program, here called "program."

Open a terminal and type sudo mousepad /etc/xdg/autostart/program.desktop. You can replace mousepad with nano or vim if you're not in an X windows system. Now add the following information, of course editing it for the specific program you want to autostart.
[Desktop Entry]
Comment=This is just a simple program.
Exec=program -options
The Name field should give the displayed program name. Comment gives information on the program that users can view when they want to know more about it. Exec gives the actual command to be executed, and can be almost anything you would type into a terminal to launch a program. Icon gives the full path and name of the icon file, but isn't absolutely necessary for autostarted applications. The rest of the options aren't critical, but if you like the Xfce wiki gives more information on all these features.
Now save and close the file. Now when you restart X the program should start automatically.

2: Copy method

You can simply copy a .desktop file which already exists, assuming one does exist. If a .desktop file exists for a program, indicating it is showing in the applications menu, it will be located in the /usr/share/applications folder. Look for it, it will usually be named similar to the Debian package name, and make note of it. Now open a terminal and type sudo cp /usr/share/applications/program.desktop /etc/xdg/autostart. In this case program will be started when X is restarted.


Anonymous said...

I needed to autostart mythfrontend for my MythBuntu box, but didnt know how. Thanks for the tip

Boot said...

Glad to help!

Marf said...

Thanks for your informative article. Just one addition: if you want to autostart an application for a single user, put the .desktop file in ~/.config/autostart

Otto said...

finally solved it!