Describes how to setup keyboard shortcuts for hot keys that trigger a command that requires sudo
Note: It is important to understand what you are allowing NOPASSWD to bypass and correctly lock down scripts being accessed
mochijump@computer:~$ ls -l /usr/local/bin
total 8
-rwxr-xr-x 1 root root 118 Feb 11 09:13 max-brightness-screen
-rwxr-xr-x 1 root root 69 Feb 10 11:50 turn-off-screen
mochijump@computer:~$ cat /usr/local/bin/turn-off-screen
#!/bin/bash
echo 0 > /sys/class/backlight/intel_backlight/brightness
mochijump@computer:~$ cat /usr/local/bin/max-brightness-screen
#!/bin/bash
cat /sys/class/backlight/intel_backlight/max_brightness > /sys/class/backlight/intel_backlight/brightness
mochijump@computer:~$ sudo cat /etc/sudoers.d/hot-key-permissions-for-screen
# Personalized by MochiJump
mochijump ALL=(root) NOPASSWD:/usr/local/bin/turn-off-screen
mochijump ALL=(root) NOPASSWD:/usr/local/bin/max-brightness-screen
mochijump@computer:~$ gsettings get org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ name
'turn off screen'
mochijump@computer:~$ gsettings get org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ command
'sudo turn-off-screen'
mochijump@computer:~$ gsettings get org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ binding
'<Super>MonBrightnessDown'
mochijump@computer:~$ gsettings get org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/ name
'max brightness screen'
mochijump@computer:~$ gsettings get org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/ command
'sudo max-brightness-screen'
mochijump@computer:~$ gsettings get org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/ binding
'<Super>MonBrightnessUp'