[Ryedale] Executing scripts on login
Paul Teasdale
pdt at ryetek.co.uk
Thu Feb 14 20:32:58 GMT 2008
On Tuesday 12 February 2008 09:11, Al Girling wrote:
> Hi folks,
>
> On Sat, Oct 20, 2007 at 05:07:15PM BST, Al Girling wrote:
>
> --%<--
>
> > From what I've read it should be a simple matter of adding the script
> > name to .bash_profile and the next time I log in the script will be run.
> > This doesn't happen, so I'm running it from .bashrc, which is OK, but
> > means everytime I open another term/shell the script is run.
> >
> > Can anyone tell me if .bash_profile is the correct place to run this
> > from or if you have other info which might be helpful.
>
> This took a little solving as all the normal start-up file failed to
> work. It seems that my choice of GNOME as desktop is the cause as it
> calls its start-up files from ~/.config/autostart/ which are created
> from Desktop > Preferences > Sessions which has a tab Startup Programmes
> which is self explanatory. This works, but means that if I choose to
> install another window manager I'll probably have to set up other files
> and when trying .xsession discovered the presence of .xsession prevented
> the GUI login from working.
>
> Any way, progress was made and the problem solved.
>
Hi Al,
It is possible to use $HOME/.xsession but it took a little reading of the
manual to work out exactly what you need to do. If you do a 'man xsession'
or 'man xinitrc' there is a clue in each of these manual pages.
If you want to start things up globally for every user then you can add extra
script files in /etc/X11/Xsession.d. You need to make sure that the name of
your file comes before 99x11-common_start. So for example you could add a
file called 98my_local_stuff and type your startup scripts into this file.
The files in this directory are actually sourced rather than executed but
that does not matter. All it means is they will get executed in the same
shell rather than a new shell for each script file. Furthermore if you were
to put #!/bin/bash, for example, at the top of the file you created it will
be ignored.
If you want to start things up on a per user basis then you can use
$HOME/.xsession by creating the file and typing your startup script in that.
As an administrator is possible to turn the use of the $HOME/.xsession file
on or off in /etc/X11/Xsession.options by specifying the
setting "allow-user-xsession". In Debian Etch this is on by default meaning
that if the file exists it will be used.
The key bit of information is knowing that when you specify a $HOME/.xsession
file you must tell X what to do after the file is dealt with otherwise
execution will end and nothing happens and that's why your GUI did not start
up. Therefore the last line of the $HOME/.xsession file must start the window
manager that you want like this:
exec gnome-session
Or 'exec fluxbox' or 'exec startkde' or whatever.
Going back to the global options in /etc/X11/Xsession.d for a second you will
notice that the file /etc/X11/Xsession.d/99x11-common_start contains only
this 'exec' line and that's why it's important to create a file which comes
earlier in the list than 99x11-common_start.
I have actually tried both of these methods above and they do work.
Furthermore I think they should work for any window manager.
The only thing I'm not sure about is that if you specify a $HOME/.xsession
file I'm not sure if any of the files in /etc/X11/Xsession.d get called. If
they don't then it may mean things like gpg-agent will not get started when
using a $HOME/.xsession file in which case you may need to start some
additional things up for yourself. This should be fairly easy to work out.
Hope this helps,
Regards,
Paul.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mailman.lug.org.uk/pipermail/ryedale/attachments/20080214/5c7c90df/attachment.bin
More information about the Ryedale
mailing list