-   Linux - Newbie (
-   -   I want to automatically run a program when a user logs on their account (

bad_andy 01-31-2005 07:39 PM

I want to automatically run a program when a user logs on their account
I know how to use rc.local, but what about automatically running something in the X environment when the user first logs in?

trickykid 01-31-2005 07:45 PM

Are you wanting this to be an X program or from a console or terminal?

Creating a .bash_login usually works for either way.

linuxLuser 01-31-2005 07:48 PM

isn't that what .xinitrc is for? I may be misunderstanding your question, but in general when the X window system starts up, it checks for the .xinitrc file in the user's home directory. It will then execute what is in that. For instance, I have this:

xscreensaver &
xpenguins -n 36 &

which will execute the xscreensaver (starting it up), then xpenguins (giving me a bunch of crazy penguins running around everywhere :)) and then finally starting my window-manager (enlightenment).

-- the dudeman

bad_andy 01-31-2005 07:55 PM

I think we're on the same page, linuxluser, but I don't see that hidden file in my home directory. What next?

jhcatch22 01-31-2005 11:52 PM

Missing .xinitrc
I have the same problem, I never had a .xinitrc file in my home directory. I added one to run some commands to remap my mouse wheel so it will scroll properly, but the .xinitrc file never gets parsed (as far as I can tell). The .xinitrc file is shown below:

# (c) 2000-2002 MandrakeSoft
# $Id: xinitrc-xinitrc,v 1.2 2002/09/10 05:53:43 flepied Exp $

# Set a background here because it's not done anymore
# in Xsesion for non root users
if [ "`whoami`" != root ]; then
xsetroot -solid "#21449C"

# the following was added by CJW 2005-01-24 for wheel mouse support
/usr/X11R6/bin/xmodmap -e "pointer = 1 2 3 6 7 4 5"
BINARY=$(which imwheel)
$BINARY -k -p -b "67"
# end addition 2005-01-24

exec /etc/X11/Xsession $*

If I run the "/usr/X11R6/bin/xmodmap -e "pointer = 1 2 3 6 7 4 5"" in a shell everything works fine.

Note that I'm running Mandrake 9.2 and KDE with a graphical logon screen.

If anyone has any thoughts as to why .xinitrc doesn't get parsed, please let me know!


h2gofast 02-01-2005 11:57 AM


If I run the "/usr/X11R6/bin/xmodmap -e "pointer = 1 2 3 6 7 4 5"" in a shell everything works fine.
same for me I have to run xmodmap after I login. it isn't getting executed from the xinitrc file.

linuxLuser 02-01-2005 08:20 PM

If you don't have .xinitrc then you can make it. The man pages (of startx) indicate that when the .xinitrc file exists, the session exits. You need to have everything run in the background except for the last command. That's why I had an ampersand on the end of every line except the last (which loads my window manager). If you don't, you can get a blank screen or a program unexpectantly exiting or something weird like that.

Sorry if I was unclear about that.

-- the dudeman

Tinkster 02-01-2005 08:55 PM

Graphical login managers (such as xdm, kdm, gdm) will
use the configuration file:


startx uses:


Try a
mv .xinitrc .xsession


All times are GMT -5. The time now is 03:50 PM.