LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   I want to automatically run a program when a user logs on their account (https://www.linuxquestions.org/questions/linux-newbie-8/i-want-to-automatically-run-a-program-when-a-user-logs-on-their-account-284679/)

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:
Code:

xscreensaver &
xpenguins -n 36 &
enlighenment

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:

#!/bin/sh
# (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"
fi

# 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!

thanks,
jh

h2gofast 02-01-2005 11:57 AM

Quote:

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:

~/.xsession

startx uses:

~/.xinitrc

Try a
mv .xinitrc .xsession


Cheers,
Tink


All times are GMT -5. The time now is 05:00 AM.