gksudo is not taking full focus - python, glade

Ubuntu 18.04.6 LTS. I got this script in python, and its uses Glade as a gui.

Here is the main file: https://github.com/stuk88/UbuntuClearMemoryCache/blob/master/main.py

So. The code at fault here is:

runAsRoot("gksudo sysctl vm.drop_caches=1")

And I dont know why dksudu is not taking focus. Switching windows with alt+` is not working either.


You are trying to run a terminal command with gksudo. That will start the process, but of course leave you no way of interacting with it. You probably rather want to launch a terminal application, in which that command is started.

Note that gksudo to start graphical applications is deprecated. Use pkexec, but better, prefer not to run a graphical application as root at all: have it elevate to root privileges only while actually performing the specific actions that require root permissions.