Hammerspoon: Document shortcomings of hs.brightness

Created on 3 Jan 2018  ·  5Comments  ·  Source: Hammerspoon/hammerspoon

Not working as __I__ expect, not sure if it's working as intended. But should have a note in API docs to clear up confusion if it's suppose to be this way.

I expected it to be exactly the same as if I was interacting with the brightness keys or manually adjusting the brightness slider in OS X.

What it actually does for me is just set the brightness correctly via hardware it looks like but ends up being 'temporarily'. But OS X isn't informed, and it's own brightness controls kick in and 'fixes' the value I set.

For example, I via OS X key or slider set the brightness very low. Run hs.brightness.set(70), I see it light up, then immediately the display dims back to very low on it's own. When set to 70 for that brief moment the OS X brightness slider never moves.

If that's not the intention for this, then maybe a note in the docs to explain what the purpose of it is? Because right now I can't think of a usefulness for it's current functionality as setting a new brightness value is only temporary.

MacBook Pro 13" retina 2015
OSX 10.13.2 (high sierra)
With / without external monitor tested; same result.

docs help wanted

Most helpful comment

@hnry I had the same problem but found a fix. In System Preferences > Energy Saver > Battery, uncheck “Slightly dim the display while on battery power”. It worked instantly as soon as I clicked the check box 😄

All 5 comments

@hnry I had the same problem but found a fix. In System Preferences > Energy Saver > Battery, uncheck “Slightly dim the display while on battery power”. It worked instantly as soon as I clicked the check box 😄

Unfortunately I'm not aware of a way for us to set the brightness in a way that macOS will recognise. Disabling things like the battery dim and also the automatic brightness, may well help, in that macOS will be less likely to set the brightness itself.

We could certainly document that more clearly though!

@cmsj - Is this of any relevance? https://github.com/Bensge/NativeDisplayBrightness

Can confirm that unticking “Slightly dim the display while on battery power” works. The thing that was so confusing to me is that hs.brightness.set(70) works as expected from the Hammerspoon console but not in the script (even with a checkmark in mentioned checkbox)

As of writing this, I'm unable to reproduce the success experienced by unchecking

Slightly dim the display while on battery power

Relevant code:

function alternateLaptopScreenBrightness()
  if hs.brightness.get() == 0 then
    hs.brightness.set(100)
  else
    hs.brightness.set(0)
  end
end

Any update on this?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

agzam picture agzam  ·  3Comments

luckman212 picture luckman212  ·  4Comments

jiahut picture jiahut  ·  3Comments

asmagill picture asmagill  ·  4Comments

Pancia picture Pancia  ·  4Comments