Closing script on logout

I start a non-terminating script from the i3 config file and when I log out, that script is not terminated. When I log back in, another instance is created. Is there a script that I can run at logout that would kill the script?

Without knowing your script and how you start it:

perhaps add a check condition to the beginning of your script - that checks whether an instance of it is already running and only allows it to be started when it’s not …?
… or kill the previous instance and only then start another …

If you want a simple answer then

If for some reason a script specifically needs to run on logout then there is (AFAIK) no simple directory of scripts as there is for startup, however this post suggests using a library called i3ipc which supports Python, Jua, or JavaScript and interfaces with i3.

There is also a already existing directory called
.bash_logout
where you could take care of the non-terminating script

1 Like

A bit late but using .bash_logout did the trick.

Thanks mate.