Premise: All OS functionality is code
Conclusion: I must have a way to emulate said code.

I would like to figure out how to have the exact same brightening/dimming display mechanism currently mapped to F1/F2 on my keyboard but via Terminal. I've googled and found a number of references to pmset, which is fascinating, but not the same goal.

Any thoughts on bash/c++ or other cli-based tools I can use to dim or brighten my display in OSx 10.6.7?

  • 1
    I have no idea about the topic, but a quick Google yields mattdanger.net/2008/12/…. Does this have anything to do with what you're asking for? – Vervious Jul 12 '11 at 5:47
  • 1
    Your question is perfectly on topic here, no need to be migrated. – slhck Jul 12 '11 at 7:02
  • @slhck - thanks! @Nano - that was the first thing I found! It looks potentially utilize-able, but seemed like a great deal more effort than I expected. The heart of my Q here is how can you emulate the output of tapping F1? It must be possible... or so I continue to stubbornly assume. – mbb Jul 12 '11 at 14:39
  • Also, the mattdanger concludeds with adding in a boot up hook. I would like to have more of a readily-available CLI call. – mbb Jul 12 '11 at 14:43
  • You only need the login hook if you want a specific brightness upon booting. /path/to/brightness just refers to where you install that program. This is your readily-available CLI call. Except for the IODisplaySetFloatParameterfunction call (and determining which display, if it's not all of them) , it's all boilerplate code. – Daniel Beck Aug 30 '11 at 6:53

Based on the brightness program from @Nano8Blazex's comment, that is assumed to be installed on your $PATH:

Add the following lines to .bash_profile (assuming bash shell) and you can then use dim and lighten as commands for F1 and F2, respectively. Both work only on display 0 as listed by brightness -l.

function modify_brightness {
    local delta=$1
    current=$( brightness -l | grep "display 0: brightness" | cut -d" " -f4 )
    #echo "Current brightness is $current"
    new=$( echo "$current+($delta)" | bc )
    #echo "New brightness is $new"
    COMMAND="brightness -d 0 $new"
    #echo "Executing $COMMAND"

function dim {
    modify_brightness -0.0625

function brighten {
    modify_brightness 0.0625
  • Great choice. I'm running down a rat hole of needing to find a gcc option for 10.6 OSX w/o Xcode, but I'll just find my boot dvd and install it. Cheers. – mbb Sep 4 '11 at 21:14
  • @mjb That blog page contains a download link for the compiled binary. – Daniel Beck Sep 4 '11 at 21:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.