Reaction to user logout command while in X

Discussion in 'Linux' started by Capum130, Feb 10, 2016.

  1. Capum130

    Capum130 MDL Member

    Jan 25, 2011
    228
    4
    10
    #1 Capum130, Feb 10, 2016
    Last edited: Feb 13, 2016
    Hello
    There is this ubuntu server installed with CLI only. I added X and JWM just to access firefox. Once in a while I have the habit to logout (sometimes it returns unable to logout "not login shell" —well this another matter ) while X running, so it hangs up, then the only way is rebooting he VM.

    I tried to make an alias for each of these frequently used commands and further variations:
    logout='pkill -TERM X ; logout'
    exit='pkill -TERM X && exit'
    logout='pkill -TERM X && pkill -TERM -u $USER'

    also method with function:

    logout() {
    pkill -TERM X
    logout *(or 2 or 3)
    }

    pkill() {
    if [[ $@ == "-TERM -u $USER" ]]; then
    command pkill -TERM X
    command pkill "$@"
    fi
    }
    *change %USER with username since bashrc located at user specific path.

    I realized it won't work because whole command is given on terminal on X and since interface change to CLI after first command, it wouldn't run the second. OR not?
    Summary: The .bashrc is unable to run second command. Why?

    I appreciate this place very much and all the help provided past and forth.