[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Logon/off scripts



bob@evilkat.com wrote ..
> > > I'm wondering where I would put a simple bash script so that it runs
> > > when I log a user on, then off.
> > 
> > .bash_login		for login stuff.
> > .bash_logout	for logout stuff.


Then there's /etc/profile for system-wide logins scripts.

> AFAIK this only works if the person is logging into a console.  
> I have yet to figure out a way to do the same when a user logs into 
> gnome or kde.

In KDE, if you need a gui, you can simply put your script in ~/.kde/Autostart/

I usually put something in there that fires up ssh-agent and loads my keys. Presto -- Click'N'Go SSH sessions.

If you don't need a gui, you should put your script in ~/.kde/env/ for startup and for shutdown, put it in ~/.kde/shutdown/.

From my /usr/bin/startkde (Xandros 3) (line 60):

  # Source scripts found in <localprefix>/env/*.sh and <prefixes>/env/*.sh
  # (where <localprefix> is $KDEHOME or ~/.kde, and <prefixes> is where KDE is installed)
  #
  # This is where you can define environment variables that will be available to
  # all KDE programs, so this is where you can run agents using e.g. eval `ssh-agent`
  # or eval `gpg-agent --daemon`.
  # Note: if you do that, you should also put "ssh-agent -k" as a shutdown script
  #
  # (see end of this file).
  # For anything else (that doesn't set env vars, or that needs a window manager),
  # better use the Autostart folder.
  
  exepath=`kde-config --path exe`
  
  for prefix in `echo "$exepath" | sed -e 's^/bin/^/env/^g;s^:^ ^g'`; do
    for file in "$prefix"*.sh; do
      test -r "$file" && . "$file"
    done
  done

... (line 235) ...

  echo 'startkde: Running shutdown scripts...'  1>&2
  
  # Run scripts found in $KDEDIRS/shutdown
 for prefix in `echo "$exepath" | sed -e 's^/bin/^/shutdown/^g;s^:^ ^g'`; do
    for file in `ls "$prefix" 2> /dev/null | egrep -v '(~|\.bak)$'`; do
      test -x "$prefix$file" && "$prefix$file"
    done
  done


Your distribution may use a totally different KDE startup/shutdown mechanism.

As for GNOME, maybe the GNOME list or a GNOME fan can help out. Other window managers have their own start/stop sequences.

What you do may depend on whether what you're starting requires a GUI or not. i.e. if you're just pre-starting some xterms, for example, sticking them into .xsession might not be a bad idea. Nor would be starting them in a launcher script in ~/.kde/Autostart. Except the latter would be KDE-specific, of course.


And of course, there is no better source than reading the manual pages for these things. Xsession, kdm, Xsession.options should be enough to get you started.

And yes, the road to starting a graphical desktop is long and twisty, and filled with rabbit holes to fall into. Just persevere through it, for much, young Jedi, learn you will.

mike/


-
To unsubscribe, send email to majordomo@silug.org with
"unsubscribe silug-discuss" in the body.