I'm trying to make a program that allows me whenever the user want, shutdown or restart the computer. I'll send this to my friends so I don't know which operating system. I'm using tkinter too,here is an example codes;
import subprocess
import os
time = "10"
if os.name == "posix":
subprocess.call(["shutdown", "-h", time])
elif os.name == "nt":
subprocess.call(["shutdown", "-s", "-t", time])
However, on linux, it's asking password to user before shutting down. So this program is useless if asking password before shutting down. I tried to use %admin ALL = NOPASSWD: /sbin/shutdown
after if
statement but it doesn't work either. How to pass this password thing on linux?