Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19
Hello & running a command when xsession is closed
Results 1 to 5 of 5

Thread: Hello & running a command when xsession is closed

  1. #1

    Hello & running a command when xsession is closed

    Hi everyone,

    I'm new to this board. I have been using linux from time to time those two last years. I had to switch back to windows for various businesses but I'm now back to slackware and fine tuning it.

    Here is a question:
    I would like a command (clear and then logout) to be run when user exits the xsession (by the user menu and maybe by ctrl altt backspace).
    I tried adding them to the xinit file but it is obviously not the right way. It has no effect.

    It would complement a startx put in .bashrc and so replace xdm/gdm.

    Thanks in advance,
    P.

  2. #2
    Moderator
    Good Guru
    Schotty's Avatar
    Join Date
    Jul 2001
    Location
    Milwaukee, WI
    Posts
    5,760

    Re:Hello & running a command when xsession is closed

    Welcome aboard!

    I didnt know to be quite hones until I googled this and found this article :

    Link
    Code:
    Create a logout script that runs commands when you log out. For example, you might want to back up critical work and delete unwanted files.
    
    # Delete all core files.
    find ~ -name 'core' -exec rm\{\} \;
    # Delete all emacs backup files.
    find ~ -name '*~' -exec rm \{\} \;
    # Make a tar file of the "working"
    # directory and save it in "tmp".
    # First remove yesterday's tar.
    rm ~/tmp/working.tar
    tar cf ~/tmp/working.tar ~/working
    
    C-shell and tc-shell users put the commands in the file ~/.logout. Bash shell users put the commands in the file ~/.bash_logout. Bourne and Korn shell users use the following steps to create a logout script.
    
       1. Create a file in your home directory called .logout that contains commands you want executed when logging out.
       2. Mark the file as executable.
    
    chmod u+x ~/.logout
    
       3. Add the following line to the ~/.profile file.
    
    trap "~/.logout" 0
    Let me know if this applies or not.


  3. #3

    Re:Hello & running a command when xsession is closed

    Thx for the answer! However this is not really what I'm looking for. I need to run a script or just the plain logout command when I exit X; not running a script at logout.

    Anyway, I appreciate your help. This is not a critical issue but I will keep looking ...

    Cheers,
    Pierre

  4. #4

    Re:Hello & running a command when xsession is closed

    I just found that I should put the commands at the end of the startx file. Problem is now that 'exit' exits the script rather than exiting the bash session. Logout is not accepted either ...

    P.

  5. #5

    Re:Hello & running a command when xsession is closed

    Got it working! I added this to .bashrc:

    if [ `tty` == /dev/tty1 ]; then
    startx -- -nolisten tcp
    clear
    logout
    fi

    This way, just after entering my password I go in X and I logout on a clean console when I exit X.

    P.

Similar Threads

  1. Replies: 5
    Last Post: 04-30-2007, 08:43 PM
  2. Killing an XSession
    By jro in forum Linux - Software, Applications & Programming
    Replies: 3
    Last Post: 03-25-2006, 02:28 PM
  3. Putting more commands behind an already running command
    By Uranus in forum Linux - General Topics
    Replies: 4
    Last Post: 11-22-2004, 10:52 AM
  4. running remote command, then leave it running
    By Blaqb0x in forum Linux - General Topics
    Replies: 1
    Last Post: 10-03-2003, 10:36 PM
  5. opening Linux XSession in WindowsXP
    By coltrane in forum Linux - Software, Applications & Programming
    Replies: 2
    Last Post: 02-27-2003, 03:43 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •