Issue
I created a script that runs when I press a combination of keys, it means that I call my "script.py" from my "keyboard customize shortcuts".
It does not work properly because when I run my script from the terminal, I have to type my sudo password.
Just to be more clear, if I run my script without sudo, it shows this: ImportError: You must be root to use this library on linux.
So, it must be like this sudo python3 script.py
, then it ask for my password (which I rather to not).
Solution
I fixed it.
I created a file inside "/etc/sudoers.d
" named "script" without extension.
Inside the script file I put "myuser ALL=(ALL) NOPASSWD: /home/user/Documents/Scripts/script.py
".
Then I gave the right permissions with "chmod +x /home/user/Documents/Scripts/script.py
"
Finally I put "sudo /home/user/Documents/Scripts/script.py
" on my custom shortcut.
Thanks!
Answered By - Stone Garden