Question

The idea being that, once the brightness passes a certain level, one could switch to a different visual scheme to give greater visibility. Also, if it could be some sort of listener type thing, that would be even better, but I'll take what I can get.

Was it helpful?

Solution 2

epatel was pretty close, I just had to change the AppleGraphicsControlBacklight keyword to something else to get it to work on my macbook, so I'd guess that this is something that might change between OSX versions and/or macbook versions.

I threw together a short ruby script to print out a little visual indicator on the command line.

# grab the string containing the values
brite_string = `ioreg -c AppleBacklightDisplay | grep brightness`

# build a regex to match those vals
brite_regex  = /"brightness"=\{"min"=([0-9]{1,3}),"value"=([0-9]{1,3}),"max"=([0-9]{1,3})/

# match them
match_data = brite_regex.match(brite_string)

# extract the values from the match
min = match_data[1].to_i
val = match_data[2].to_i
max = match_data[3].to_i

# print them out nice
puts "Current Brightness"
print "["

max.times do  |i|
  print i > val ? " " : "*"
end

puts "]"

OTHER TIPS

I believe one could look it up with IOKit. Running the ioreg command in the terminal as below gives two lines where a brightness value is visible.

% ioreg -c AppleGraphicsControlBacklight | grep brightness

| | |     "IODisplayParameters" = {"brightness"={"min"=0,"value"=408,"max"=1024},"commit"={"reg"=0}}
| |   |     "IODisplayParameters" = {"brightness"={"min"=0,"value"=408,"max"=1024},"commit"={"reg"=0}}

Maybe someone with enough IOKit knowledge could put together a sample...

I am not a mac guy, but does /proc exist in the filesystem? You might want to look in that virtual file directory if it exists.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top