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?
ifstatement, you should save this line to/etc/sudoers.d/shutdown(on Debian) or similar. Make sure the file mode is0440and your/etc/sudoersfile contains#includedir /etc/sudoers.dat the end. Usevisudoto edit it if necessary.