Sample Header Ad - 728x90

Autokey - Adjusting Screen Brightness with Hotkeys (and sustaining that brightness in Awesome Window Manager)

1 vote
2 answers
368 views
In [awesome window manager](https://awesomewm.org/) , my screen brightness gets reset to 100% each time I'm away from my computer for a few minutes. **How can I get it to sustain the brightness I set prior to these screen-saver/power-management timeouts?** **Background:** Using [autokey](https://en.wikipedia.org/wiki/AutoKey) , I've created 3 scripts that enable me to adjust my screen's brightness with hotkeys. These scripts use the debian package brightnessctl to accomplish this:
sudo apt install brightnessctl
` For the sake of being helpful to others, I will include these scripts below. **Increase Brightness:**
import os
currentBrightness = system.exec_command("brightnessctl g")
brightnessLevel = str(int(currentBrightness) + 1)
if int(brightnessLevel) > 100:
    brightnessLevel = '100'
if brightnessLevel:
    cmd = "brightnessctl s " + brightnessLevel
    os.system(cmd)
    store.set_global_value("lastBrightness",brightnessLevel)
**Decrease Brightness:**
import os
currentBrightness = system.exec_command("brightnessctl g")
brightnessLevel = str(int(currentBrightness) - 1)
if int(brightnessLevel)  0:
    store.set_global_value("lastBrightness",brightnessLevel)
    cmd = "brightnessctl s " + brightnessLevel
    os.system(cmd)
While these scripts are working perfectly, I do have an issue: When I'm away from my computer for a few minutes, and then come back, my monitor will be in some type of power saving state, where the monitor has been either turned off or displays a black screen. When I wake up the monitor (by hitting a key or moving my mouse) the brightness that I previously set (using brightnessctl), has been changed back to 100% brightness. **How can I sustain my brightness settings thorough these screen-saver/power-saving timeouts?**
Asked by Lonnie Best (5415 rep)
Jan 22, 2022, 01:40 PM
Last activity: Oct 30, 2023, 10:53 PM