custom routine mac os

I want to create a routine that automatically sets the keyboard to full brightness whenever the device is plugged in and charging. When unplugged, I want that routine to set keyboard brightness to the lowest setting or turn it off completely, depending on the time of day.

What are my options? Are you aware of any 3rd party software/extension that would allow me to implement this? If these options don't exist and I need to make my own software, what keywords can I use to figure out how to access internal mac settings such as keyboard brightness?

(I am aware of the built-in auto brightness feature but that is not what I am looking for)


There is an app named EventScripts which can watch for e.g.,:

  • Power switched to mains
  • Power switched to battery

Then when the change it detected, it can run a AppleScript script or a shell script which could be coded to make the changes you've expressed.

It's $5.99 USD on the App Store and is also available from the developers website where you can download a demo version and test it out.

There is also Hammerspoon which has an hs.battery.watcher function where you could do basically the same thing for free, although it's more complicated to setup.

Note: I am not affiliated with the developers of the aforementioned, just a satisfied user of the products.