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?