Topic: [SOLVED]After-login script execution

Hi guys.

As an answer to my gdm problem (in my other topic) I was thinking of disabling gdm and making a simple console login, launching startx manually afterwards. I was wondering if there is a way to make my crunchbang execute a script (which launches startx) right after my login, to make the X starting automatical.
Anyone can help?

Thanks in advance!

Last edited by xaber (2010-07-27 19:44:28)

Re: [SOLVED]After-login script execution

If you want X to start automatically, create a .bash_profile file in your home (if it doesn't exist already) and put this in it:

if [[ -z "$DISPLAY" ]] && [[ $(tty) = /dev/tty1 ]]; then
  startx
  logout
fi
Note: ** Please read before posting **

BTW if you wish to contact me, send me an e-mail instead of a PM.

Re: [SOLVED]After-login script execution

Thank you very much Anonymous! I didn't know the DISPLAY env var, but  was thinking of something similar, like setting a new var to use as a control flag for knowing if X is already running or not and so starting X. But I have a question: why the logout command? And what's the difference between a .bashrc and a .bash_profile file?

Re: [SOLVED]After-login script execution

The logout command will log you out when X is killed. Also I just copied the code from the Arch Wiki and used it as-is.

.bash_profile gets called when you login and .bashrc gets called whenever you open a shell.

Note: ** Please read before posting **

BTW if you wish to contact me, send me an e-mail instead of a PM.

Re: [SOLVED]After-login script execution

Perfect explanation (as always as well from you Anonymous!)!
So in my .bash_profile I can add any instruction I want to be executes after I log in (obviously after having gdm disabled of course!)?

Re: [SOLVED]After-login script execution

Yes. If you're going to start some GUI apps though, you should use your DE/WM's autostart file instead. For Openbox its ~/.config/openbox/autostart.sh

Note: ** Please read before posting **

BTW if you wish to contact me, send me an e-mail instead of a PM.

Re: [SOLVED]After-login script execution

if you have a ~/.profile file use that rather than creating a .bash_profile file, it does basically the same but already exists (on statler anyway), has configs in there already, and is ignored if .bash_profile exists

- - - - - - - - Wiki Pages - - - - - - -
#! install guide           *autostart programs, modify the menu & keybindings
configuring Conky       *installing scripts

Re: [SOLVED]After-login script execution

anonymous wrote:

Yes. If you're going to start some GUI apps though, you should use your DE/WM's autostart file instead. For Openbox its ~/.config/openbox/autostart.sh

Thanks Anon, I already knew this, but thanks again!

Thanks to all for your help guys! Thank you Benji!
Think this is solved! wink