I have been searching how to change my screen's brightness with a keyboard shortcut, because my keyboard doesn't have a physical key.
A tool such as xrandr isn't suitable, because it messes with my Night Light setting.
From the terminal or from Alt+F2, these two commands correctly raise or lower the screen's brightness respectively:
Code:
xdotool key XF86MonBrightnessUp
xdotool key XF86MonBrightnessDown
However, if I add these to my custom keyboard shortcuts, they don't work.
I created a basic script to do the same thing, and I discovered something odd. This script works when run from the terminal or Alt+F2, but not from a keyboard shortcut:
Code:
#!/usr/bin/env bash
xdotool key XF86MonBrightnessUp
However, this does work from a keyboard shortcut:
Code:
#!/usr/bin/env bash
zenity --info --text='Brightness up'
xdotool key XF86MonBrightnessUp
Of course, there's the inconvenience of pressing Enter to close Zenity's display before it works.
Putting Zenity into the background prevents it from working:
Code:
#!/usr/bin/env bash
zenity --info --text='Brightness up' &
xdotool key XF86MonBrightnessUp
Obviously, running Zenity to put something on the screen somehow "activates" the screen from Bash's point of view.
How can I achieve what I'm after without having to display something on the screen?
Bookmarks