I'm trying to create a desktop shortcut that changes my monitor input by executing sudo /usr/bin/ddcutil -d 1 setvcp 60 0xF
without requiring a password. I've made an entry in the sudoers.d directory and if the command is run from the terminal no password is required as expected, but when I click on the shortcut it prompts for a password. How what needs to be done to make this shortcut run without a password?
.desktop file:
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=Windows 10
Comment=Switch Display to Windows Virtual Machine
Icon=/usr/share/icons/windows-icon.png
Terminal=true
Exec=sudo /usr/bin/ddcutil -d 1 setvcp 60 0xF
sudoers file:
myusername ALL = NOPASSWD: /usr/bin/ddcutil
The solution here doesn't work because gksu is deprecated and using pkexec instead as suggested in one of the answers still prompts for a password.