The file ~/.profile
can be used to specify commands to run when a user logs in to a session. This has the advantage over ~/.bash_profile
in that it works for shells other than bash and also works for at least some desktop environments (e.g. it works for me logging into Mate). However, I am wondering if there is an equivalent to ~/.profile
for logging out, which (unlike ~/.bash_logout
) will run commands on user logout for other shells as well as the Mate DE?
(note: I tried the obvious ~/.logout
and it didn't seem to work)
To clarify, in response to some of the comments:
I am using OpenRC, not systemd, so the answer to this question doesn't help me. This is not in any way a duplicate of that question. I am looking for something that would be independent of the init system and also per user, not system-wide (hence the comparison to ~/.profile
).
I think 'no' would be a perfectly acceptable answer, if the answer is 'no' (with perhaps an explanation of what is the 'proper' way to run commands on logout from the DE for a user).
$HOME/.profile
:test -f "$HOME"/.exitrc && trap '. "$HOME/.exitrc"' EXIT
– Mikel Jul 02 '20 at 03:15cat /proc/3087/cmdline
? – Gilles Quénot Jul 02 '20 at 17:22cat /proc/$$/cmdline
– Gilles Quénot Jul 02 '20 at 18:07~/.bash_logout
– Gilles Quénot Jul 02 '20 at 18:34~/.bash_profile
also doesn't seem to work for logging in to the DE (even though bash is my default shell); however,~/.profile
does. – Time4Tea Jul 02 '20 at 18:37