Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to execute two commands one on logon and one on logoff. For the log on one, I put my script into /etc/X11/xinit/xinitrc.d and this works.

I'd like it to be system-wide so I can use any WM.

share|improve this question
up vote 4 down vote accepted

Have a look at your display manager (lightdm, gdm, kdm, xdm, wdm).

Newer lightdm versions can have a session-cleanup-script entry in the [SeatDefaults] section of /etc/lightdm/lightdm.conf.

For gdm, you can put a script in the PostSession directory.

For kdm, xdm and wdm have a look at this answer at SuperUser.

share|improve this answer
Thanks for your answer. – igor012 Oct 4 '12 at 12:46
Thanks for your answer. I did try to add a command in Xreset but it didn"t work.I keep digging – igor012 Oct 4 '12 at 12:57
You can put exec >/tmp/Xreset.log 2>&1 at the start of the script (your Xreset command), so you can see whether the script is called at all, and you can see its error messages. – elmicha Oct 4 '12 at 13:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.