New version of my hint.

Stef Bon stef at
Mon Mar 20 23:06:12 PST 2006


I've rewritten my hint


and changed the name into:


I've deleted all PAM related chapters. Soon I will write a hint only about
PAM and use of, in combination with FUSE/encfs.

Kind regards,

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

DATE: 2006-03-21

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. 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. 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.

- 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.

  * add logging via xconsole

More information about the hints mailing list