Latest in Apple terminal

Image credit:

DimScreen simply dims your screen

TJ Luoma, @tjluoma

Once upon a time, I had an application which would dim the screen of my Mac down to 0, and then exit. Somewhere along the way I seem to have lost the app and can no longer find it.

Yes, I know I could just hold F1 and do the same thing manually, but I liked having an app that just did it for me.

So I did what any self-respecting geek would do: I wrote a shell script.

Others did the heavy lifting

Let me be clear that my little shell script wrapped in Automator was only a tiny piece of this puzzle.

First I'm going to tell you who did all the heavy lifting, and then you can decide how you want to put the pieces together for yourself. (I highly recommend reading to the end before you do anything.)

Nicholas Riley wrote a C program called brightness which I found via Matt "Danger" West's website, which I found via Google.

Matt includes the source code on his page, or you can download the original 'brightness.c' here and then you can compile it (according to Matt's instructions) using this line:

gcc -std=c99 -o brightness brightness.c -framework IOKit -framework ApplicationServices

Of course that assumes that you have Xcode installed. If you don't, you can either download and install Xcode (warning: it's 3 GB to download and I think it's somewhere between 7-10 GB when installed). If all of that seems like a lot of hassle, Matt also made a pre-compiled binary available for you to download.

Here's what I did

I wrote a shell script (dimscreen.zsh) which looks for brightness at $HOME/bin/brightness.

If it does not find it there, it will attempt to download it "automagically" from my personal website and then install it to $HOME/bin/brightness.

Once brightness is installed, it will dim the screen to 0 and then launch your screensaver.

Why does it launch your screensaver? Because otherwise when you went to use your Mac, you might have forgotten that you set the brightness to 0. If you move the mouse or type, you won't see anything. However if the screensaver is on, one of two things will happen:

  1. If you have enabled the preference which requires a password to be entered after your screensaver is turned on, you will see that prompt. (Mac OS X is smart enough to automatically turn the screen brightness up a little for you to see that you need to enter your password.)

  2. If you do not require a password to be entered after your screensaver is turned on, my script will turn the brightness up as little as possible after the screensaver exits. That should keep you from getting blinded if you are working at night. Then you can adjust the brightness to whatever level you want.

I took dimscreen.zsh and made it into an app ("Dim") using Automator.

I put dimscreen.zsh and the 'Dim' and the 'brightness' command (and the source code) all into one nice neat package and put it on my Dropbox as DimScreen.

"How do I use this?"

1) If you are the trusting type (or just impatient), download DimScreen, double click it to 'unarchive' it, and then move the 'Dim' to /Applications/ (or wherever you keep your apps) and run it. The first time you run it, make sure that you are online so that it can download the brightness utility. (It will only do that once.)

2) If you are trusting to a point but don't want the app to download anything automatically, make a directory called 'bin' in your home directory (that's the one which has the 'Desktop' and 'Documents' and 'Downloads' directories in it).

Then double-click the DimScreen.tar.bz2 file, and move the 'brightness' file to the ~/bin directryory you just created.

3) If you pride yourself on your distrust, then by all means, download the source code from the links provided above, compile the 'brightness' command on your own, and move it to ~/bin/ (where ~ is your Home directory).

(If you are someone who likes the, you might want to put the dimscreen.zsh script into your $PATH as well, so you can launch it from the command line.)

Once you have it installed, launch it via whatever app launcher you prefer. If you want to make it a "one click launch" you might consider Apptivate, a handy little launcher I reviewed previously. There are other ways to do it, of course, but Apptivate is still my preferred "I want to press this key (or "this key sequence") to run this Application/Script/etc" solution.

P.S. Yes, I know about Control + Shift + Eject

I am sure that some Mac keyboard aficionado will not have been able to wait until the end of the article, and is already writing a comment to tell me that if I press Control + Shift + Eject, then the Mac's screen will turn off.

I know. The problem is, I never remember if it's Control or Command, and do I have to hold down the fn key or not. Plus it's really not the same thing, I don't just want it off, I want it dimmed all the way down.

I still wanted an (even) easier way. I'm used to triggering all sorts of actions via LaunchBar and wanted to be able to dim my screen that way too. When I read on Apple Stack Exchange about someone who couldn't get that keyboard shortcut to work, I went looking for that old app (mentioned at the beginning of this article) and when I couldn't find it, I decided to just roll my own.

Are there other ways of doing this? You bet. If you have a preferred solution, feel free to let us know in the comments.

From around the web

ear iconeye icontext filevr