2

I have Ubuntu 20.04 installed with Unity Desktop only. No default Gnome. In this desktop on pressing the logout button I want to run a python script. One example of this is given in Script Execution at user logout (non root user), but this works in Python2 and Focal Fossa doesn't have Python2. I tried to port this script to Python3 which I couldn't.

Can you show us a way to make this script work in Python3 which is default in Focal Fossa? Or where can we start to write it from scratch?

1 Answers1

-1

If your login shell is bash you should be able to add your commands to ~/.bash_logout.

  • 3
    Thanks for the quick response. However, the script that I want to run and the one in the link should run as soon as the logout button pressed in the Unity Gui. When we put this in ~/.bash_logout, it executes much later in the logout process than we expect. – recap2000 Jun 03 '20 at 10:55
  • In that case, you might try replacing /usr/bin/gnome-session-quit with your own script (which calls the original as the final step of course). – Wayne Vosberg Jun 04 '20 at 07:01
  • I tried that. Although gnome-session-quit logs out when called from terminal, this script is not called when log out button in Unity is clicked. We prefer to make the python3 approach work if anybody can help on that. Thanks. – recap2000 Jun 06 '20 at 06:50