Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
I have no idea about the topic, but a quick Google yields…. Does this have anything to do with what you're asking for? – Vervious Jul 12 '11 at 5:47
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. – mjb 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. – mjb 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
up vote 2 down vote accepted

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
share|improve this answer
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. – mjb 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .