You are not logged in.

#1 2021-06-04 07:15:28

loggerhead
Member
Registered: 2019-07-07
Posts: 18

Logout from tty after exiting i3

I want to create custom bash logout command for exiting i3 and logging out from tty.
I put relevant commands into the function:

logout() {
    i3-msg exit # exit i3
    exit # log out from tty
}

However the exit command is not executed.
I'm not sure if I can do it like this.
Can you point out the corrent direction to achieve this?

Offline

#2 2021-06-04 07:22:42

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,490

Re: Logout from tty after exiting i3

Where do you put those?
The exit command exits the current shell which in doubt is not your tty login.

Also: is there a specific reason for the active tty? Why don't you "exec i3" from there - what will replace the tty shell and thus exiting i3 will "exit" the (replaced) tty as well.

Edit: otherwise you want to kill i3's parenting shell.

Last edited by seth (2021-06-04 07:23:27)

Online

#3 2021-06-04 08:20:13

loggerhead
Member
Registered: 2019-07-07
Posts: 18

Re: Logout from tty after exiting i3

Thanks for your answer, the resulting function looks like this:

logout() {
    PID=$(who -la | awk '{$1="user_name"; printf $7}')
    sudo kill $PID
}

I put the function in my .bashrc file.

Please set this topis as solved.

Offline

#4 2021-06-04 08:30:22

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,334

Re: Logout from tty after exiting i3

You should do that by editing the title in your first post.

Offline

Board footer

Powered by FluxBB