HOW TO Autostart Programs in Linux

Introduction

This HOWTO explains how to get programs to launch when you login into your WM (Window Manager) and/or DE (Desktop Environment).

NOTE: New users should note that ~ equals user’s home directory. Also note that these instructions should work on these Window Managers on most Distributions in addition to Gentoo.

GNOME

Programs that you wish to autostart on GNOME startup can be selected by using the Control Center. To do this, open the Control Center and then navigate to Sessions followed by Startup Programs. Click Add and either type the path, or use Browse to select your desired program[s]. If multiple programs are selected, they can be launched in a desired order.

If the GUI is not available or desireable, then one can instead modify ~/.gnome2/session-manual. Syntax is as follows:

File: ~/.gnome2/session-manual

[Default]
num_clients=1
0,RestartClientHint=3
0,Priority=50
0,RestartCommand=gdesklets
0,Program=gdesklets

[edit]

KDE

Programs that you wish to autostart on KDE startup need to be placed into ~/.kde/Autostart.

Below is an example of autostarting GAIM written in bash.

cd ~/.kde/Autostart
nano -w gaim (example script below)
File: Example script

#!/bin/bash
/usr/bin/gaim
chmod +x gaim

Below is an alternative for the same example, this time using a soft link.

cd ~/.kde/Autostart
ln -s /usr/bin/gaim gaim

You can also put .desktop files here. For example, you can drag a shortcut from the K Menu.

NOTE: This tutorial also works in other distros, I’ve allready used it in SuSe.

Taken from : gentoo-wiki.com