How to dim (and un-dim) display in automator

For those that are interested in the final script you can get it here

original question


I am trying to make a alarmclock script to wake me up. but I can't figure out how to change the screen brightness in automator.here is my workflow without brightness

I found a way to control brightness with the commandline. but I can't get it to work in automator

I'm the original author of the code listed in this hint. I originally wrote it for two reasons: first, to adjust brightness automatically by location on my iBook G4, which had no ambient light sensor, and second, so I could have my laptop turn on the backlight when a long operation finished, providing a quiet form of notification I could use while at a seminar. http://sabi.net/nriley/software/brightness.zip is 4-way universal, 10.5+. I compiled it under 10.6 with:... (see full forum page )

but when I try to use

brightness 0

or

brightness 1

I get an error in automator. error

am I using the run shell script wrong? could this be done easier in apple script? is there a alltogether easyer way to do this?

I need to turn the brightness up and down in automator how is this done?

Update I tried the apple script method you mentioned and it....showed the overlay that shows when the key is pressed but did nothing else

enter image description here


Solution 1:

Where did you install the “brightness” command? Even if you've set up your PATH in the shell rc scripts, it may not take effect for these commands because Automator isn't run from a shell. (You can set environment for all programs including GUI using ~/.MacOSX/environment.plist, but I wouldn't recommend fiddling with PATH just for this.)

I suggest changing your Automator workflow to use the full path to where it's installed, e.g.

/usr/local/bin/brightness 1

Solution 2:

To use the command line way you tried, you have to install some software. You can download it, and find install directions, here.

Another option: You can run an AppleScript from your Automator workflow to press the brightness up/down keys. Up:

tell application "System Events" to key code 107

Down:

tell application "System Events" to key code 113

Note: you may have to Enable Access for Assistive Devices for the AppleScript to work.

Solution 3:

Try having the automator run this AppleScript. It works for me!

set brightness_level to 1.0

tell application "System Events"
    tell application "System Preferences" to reveal the anchor "displaysDisplayTab" of pane named "Displays"
    tell slider 1 of group 1 of tab group 1 of window 1 of process "System Preferences"
        set value to brightness_level
    end tell
end tell