Wednesday, February 22, 2012

Kde4: Autostart


I like having total control over what gets loaded when I log on to my desktop. Thankfully Kde4 gives me very good control over this. Personally I've never been a big fan of using XDG *.desktop files for autostarting applications. I have to say that it is very simple to add autostart programs through Kde4's system settings. But I prefer using basic bash scripts to load what I want, maybe it is because I'm used to doing so with Openbox.

From what I have discovered Kde4 has essentially two user specific Autostart directories, not counting the XDG standard directories. Also it has one shutdown directory which essentially executes whatever you want when you logout. I'll explain later why that could be useful.


Assuming you have a standard Kde4 installation all of your autostart directories can be found within the “$kde4homedir” which by default is “~/.kde4” in Arch Linux and in most other distros it is “~/.kde”.

I use bash scripts for all of my autostarting in Kde4. Generally I have one folder in my homedir containing all of my scripts. From there I create symlinks to these scripts from within any of the following Kde4 autostart directories depending on what function they have. Keep in mind that Kde4 expects all bash scripts to contain the file ending “*.sh” for it to work properly. If you do not include this file ending, Kde4 will not parse these files on login.


~/.kde4/env

This directory is not commonly used to load applications. Since everything in this directory gets loaded before Kde4 actually loads any Kde4 specific libraries/apps. This can be useful if you want to set som specific variables before the window manager loads up. I generally use this directory for initiating backup scripts, setting up my window manager and graphic card related settings.

But I mainly use this for synching my homedir with my github account. What my script does is that it pulls my latest changes from my github account.


~/.kde4/Autostart

This is the main and default Kde4 autostart directory. Everything in here gets loaded after the window manager and plasma-desktop. Whatever extra applications you want autostarted on log in, should be placed here.

Currently the only things I have here are Dropbox, Haguichi, Skype, Parcellite. Nothing fancy, just things I like having started on login.


~/.kde4/shutdown

Everything in this directory runs when you logout, more specifically it runs before you logout and the logout process will wait until everything here has been executed before ending the desktop session.

The only thing I use this directory for is my backup script. When I logout it runs my backup script which synchs my homedir changes to my github repo. This essentially allows me to have the same settings across several computers. Keep in mind that you should only do this if you are sure that you are running the same version of everything on every computer that synchs your homedir. Otherwise your dog will burst into flames. You also have to ensure that your script is very selective with which directories gets synched to github as well. What my script looks like and how it works, is reserved for another post.

No comments:

Post a Comment