Monday, March 8, 2010

EyeSaver.app


So I've been fooling around with Applescript for a while now, and I decided to give myself a little project. After a long day of sitting and staring at computer screens, my eyes aren't as happy as they were in the morning. When I get in my room and shut the lights off in order to just relax, the only thing that bothers me is the brightness of my screen. Of course, you might say, just turn the stupid brightness down. Well that would be a good idea but that doesn't mean that the white is gone, and it also reduces the focus of the screen, since the colors are getting closer to one another. I looked for a way to fix this problem, without causing the others, and it was quite simple; just invert the colors. With colors inverted, it is harder to view pictures and surf the internet, but I am not one to do that too often. Mainly, I sit on my computer, talk to friends on AIM (I don't MySpace or Facebook, I hate them). I also write my occasional program while sitting in my room.

Apple has a built in color inversion keyboard shortcut (Command + Option + Control + 8). I use this quite often now when I get home and my eyes need to relax but I am unable to get off the computer for either homework or etc. With the new Apples, however, they have a unique little feature that uses the ambient light sensors in the computer to auto-dim your display when the room gets darker. This function is great, and I wanted to write an applescript that utilizes that function with the needs of my own. I created an applescript that uses a C program to determine the current brightness of the display. The C program, as well as some others, is all thinks to Amit Singh, and can be viewed here. I revised the program a tiny bit, and instead of it printing the results to the screen, it writes them to a specific file.

The applescript I created first prompts the user whether the colors are currently inverted or not. It then creates a new folder in your /Library/Application Support/ folder called "EyeSaver." The C program saves a small txt file with the current brightness reading into that folder. The script then reads that value, and acts accordingly. The screen brightness is recorded as a value between 0 and 1, 1 being the brightest. If the screen brightness is below .5 (I have set that as default), then the applescript runs a quick "key code" command which inverts the colors for the user. It records whether or not the screen is inverted by reading a variable either as a 1 or a 0, then stores the new value in the variable if the colors were switched. The program is still in it's beginnings, and only either runs for a set number of seconds, or until you "sudo kill" it haha. I am looking to find a way so that the program can be running in the background or quit at any time.

The program takes up minimal CPU usage and barely any memory. I am confident that it works on a majority of Macs. Any questions or comments and I would be more than happy to reply.

5 comments:

Anonymous said...

how can I uninstall this action on my Mac?

r3d 4uerb4ch said...

You can uninstall EyeSaver as simply as any other Mac OS X application: by dragging it to the trash bin.

If you would like to completely remove any traces of the application, there is a folder named "EyeSaver" that is created in " /Library/Application\ Support/ " which holds text information.

Anonymous said...

ur a dipshit

adam said...

How do i stop this application?

r3d 4uerb4ch said...

You can quit the application by selecting 'Quit' when prompted, pressing Command+Q while it is running, right-clicking the icon in the dock and selecting "Quit Eyesaver", selecting "Eyesaver" in the menu bar and selecting "Quit Eyesaver", using Activity Monitor to locate and quit Eyesaver, or using the "top" command in terminal to locate Eyesaver's PID and killing it. There is a bug with one of the "Quit" prompts where it will continue to ask you questions, but I have added another "Quit" button that will end the program. I'm working on a fix for that bug.