A Custom Monitor Rest Mode
Last year, I bought a new Mac mini and a Redmi G Pro 27U monitor.
This monitor is pretty good overall. At around 2,000 RMB, it performs well in many areas, but for me it has two small drawbacks:
- It is a bit slow to wake up, taking about 5 seconds when waking from the keyboard.
- After the monitor goes to sleep, I can no longer use Xiao Ai voice commands.
I looked through the monitor settings and could not find an option to keep it on standby without sleeping, so I decided to make one myself.
Basic idea: This is a miniLED monitor. When HDR mode is enabled in macOS, the system can control the monitor brightness directly. This does not work in SDR mode, where brightness can only be adjusted through the monitor itself. Because of miniLED local dimming, when the brightness is set to 0, the whole panel stops emitting light.
So all I need to do is set the brightness to 0 when I am not using the computer. This effectively turns off the monitor panel and saves power, while the system keeps running and can still respond to Xiao Ai commands at any time.
Prerequisites
- A miniLED monitor with HDR enabled in macOS - System Settings - Displays.
- One Switch - Keep Awake.
- Hammerspoon.
Implementation
1. Install Hammerspoon
- Go to the official website and download Hammerspoon.
- After opening it, click Hammerspoon -> Open Config in the menu bar.
- This will open
~/.hammerspoon/init.lua.
You can also open ~/.hammerspoon/init.lua directly with an editor such as VS Code.
2. Configure init.lua
Paste the following code into init.lua:
1 | -- Screensaver dimming mode: |
Save the file.
3. Reload Config
Click Hammerspoon -> Reload Config in the menu bar.
The setup is now complete. You can press Control + Command + Q to lock the screen and test the effect.
Conclusion
With this custom script, I got the monitor rest mode I wanted.
Limitations:
- On the macOS login screen, the script cannot listen for events and restore brightness. You can temporarily adjust brightness manually with the brightness keys on the keyboard.
- Compared with true sleep, this will use more power. I have not tested it, but I suppose the difference is not too large.
Advantages:
- There is no need to wait for the monitor to wake up, and I do not need to worry about issues such as burn-in.
- Xiao Ai is always on standby. Last night, I called Xiao Ai in the middle of the night to turn on the air conditioner for me.
