New version of my hint- second try.

Stef Bon stef at
Thu Jul 27 12:30:23 PDT 2006


I've adjusted my hint:


about stopping and starting scripts when using KDM as login manager.

I've added a special note,  which points to an other hint I've written about 
starting and stopping dbus. This is important because in the BLFS book this 
hint (execute-session-scripts-using-kdm.txt) is mentioned when installing 
dbus, but not the hint about dbus.

Kind regards,

Stef Bon

-------------- next part --------------
AUTHOR: Stef Bon <stef at bononline dot nl>

DATE: 2006-07-09

LICENSE: GNU Free Documentation License Version 1.2

SYNOPSIS: Execute scripts at begin and end of a KDE-session using KDM.


This hint is about the ability to execute scripts when a KDE session starts 
and when it stops. 

Earlier I wrote a hint about this using PAM, with the help of the module 
pam_script. I discovered that PAM is not the best place to do so. PAM is not 
the place to start scripts, KDM is. KDM provides a very easy way via the 
Xstartup and Xreset files to execute scripts. PAM has the abilty to do something 
with the credentials provided at login, with the help of a module called 

Original hint is on, 
"Installation and configuration of sessionscripts using KDM".


This hint requires sufficient knowledge of LINUX in general, and scripts in 


1. KDM: the files
2. Examples
3. TODO and suggestions

1. KDM: the files

KDM uses some files to start and stop:

. Xstartup 
run as root, after a user succesfully logs in. 

. Xsession
runs with permissions of the authorized user, to start the desired session (KDE).

. Xreset
run as root, after the user session has ended.

Where Xstartup is the place to start things up, Xreset is the place to undo these 

For more information about these files look at the handbook of KDM.

By adding the following code to the Xstartup file:

-- snip --

for script in /etc/session.d/kdm/startup/*.sh; do

	if [ -x $script ]; then
		eval $script $USER kdm



and the code to the Xreset file:

-- snip --

for script in /etc/session.d/kdm/reset/*.sh; do

	if [ -x $script ]; then
		eval $script $USER kdm



Create the directories where the scripts go:

install -m755 -d /etc/session.d/kdm/startup
install -m755 -d /etc/session.d/kdm/reset

The files in these directories must be accessible for every ordinary user: 
therefore the permissions are 755. 
All scripts in these directories should have the same permissions: 755.

Every user should be able to execute the script, but only root is able to 
modify them.

2. Example

I'm using this construction myself. The scripts which I let start when a (KDM)session starts are:

. dbus (the session part of it). I've written a hint how I've done this:

. fusesmb (browsing the smb network using FUSE). I've written a hint about this too:

. (un)mounting cifs shares. 

. syncing directories from one central place using rsync.

The first two are described in hints also available.

Look at, My projects, 
"Installation and configuration of sessionscripts using KDM"
for the most recent documentation and scripts.

3. TODO and suggestions

The construction is working, but is not complete:

- it does no logging and proper userfeedback (on the screen) 
with the hint xconsole_setup.txt (unmaintained: in hints/downloads/files)
you'll find a way to launch xconsole at startup by root. Using logger and 
adjusting /etc/syslog.conf it's possible to write messages to it, which
appear just before the splash screen of KDE comes up.
On my website is described how to do that.

- scripts are executed in the order the command

for script in /etc/session.d/kdm/startup/*.sh; do


Maybe there should be an order. Some scripts first and others later. Just 
like the rc script works to start and stop scripts in the /etc/rc.d structure.

- I'm testing FreeNX now. It turns your desktop into a terminalserver for
X11 sessions. You should test it!
There is a hint for LFS already!! 
It does not work with KDM, so does nothing with the construction I'm using.
I'll check for a sollution.

  * Thanks to the author of pam_script, Izak Burger, for his module and 
    some usefull hints.

  * Initial hint.
  * added chapter 3. TODO and suggestions
  * removed all PAM related chapters. Soon a new hint only about this will follow.
  * added a chapter about the examples

  * add logging via xconsole

More information about the hints mailing list