The MP3car.com Store  

Welcome to the MP3Car.com forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. Registering will also remove advertisements. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Go Back   MP3Car.com > Mp3Car Technical > MacCar

Reply
 
Thread Tools Display Modes
Old 07-18-2006, 09:29 AM   #1
Low Bitrate
thanassius's CarPC Specs
 
thanassius's Avatar
 
Join Date: Apr 2006
Location: Maryland
Vehicle: 2000 VW Jetta
Posts: 82
My Photos: (11)
Script/Action to Dim Screen based on time of day

A few months back, I had the idea to use an Apple Script or Automator Workflow to check the system time, and automatically dim the screen at a certain time each day. This way the screen wouldn't be blindingly bright at night, but would be at full brightness during the day.

My idea was to have the code check the system time, and at say, 7pm, take the brightness down a few notches. On the flip side, anytime between say 6am and 6:59pm, it would adjust back to full brightness.

I don't really know any Applescript. I tried recording an action (like a macro in MS office) but that didn't work. I was also unsuccessful at creating an Automator Workflow to accomplish this (I can't get Automator to allow access to things in System Prefs). I've tried searching to see if someone already did this, but I haven't had any luck. Is this even possible? Is the Mac Mini capable of adjusting the dimness of an external display (meaning, can this type of thing only be done on a notebook)? Thanks for any help anyone can provide!
thanassius is offline   Reply With Quote
Sponsored Links
Old 07-18-2006, 10:31 AM   #2
AMP Creator
 
aychamo's Avatar
 
Join Date: Jun 2006
Posts: 442
My Photos: (0)
You know, I think I looked into this too. I think from what I found the only real way was to "stuff" the keyboard buffer (or whatever) with the right key-combo to dim the screen (ie, Fn-F1 or Fn-F2). It sures seems like there should be an easier way.

I have no idea if external displays can be dimmed either. I only have a notebook. I gave my dad a MacMini for Christmas to replace his fried Dell, so maybe I can give him a ring and see if he can dim the monitor, etc.
__________________
- http://www.aychamo.com
aychamo is offline   Reply With Quote
Old 07-18-2006, 11:59 AM   #3
Low Bitrate
thanassius's CarPC Specs
 
thanassius's Avatar
 
Join Date: Apr 2006
Location: Maryland
Vehicle: 2000 VW Jetta
Posts: 82
My Photos: (11)
I know, you'd think someone else would need this functionality. What exactly do you mean by stuffing the key combination? Into an applescript? My coding skills aren't the greatest in general, and they're virtually non-existent on a Mac.

The Mac Mini that's going in my car is on my desk at home next to my PowerBook, so I can check as well. I think I did this a few months back, and I *think* it's not even an option on the Mini. My guess is that OS X detects what hardware it's being installed on and enables this feature accordingly. If that is in fact the case, maybe there's some way to trick it into thinking the Mini is notebook (but then there's the whole issue of whether or not the touch screen will respond if we tell it to dim).
thanassius is offline   Reply With Quote
Old 07-19-2006, 01:49 PM   #4
QCar Creator
Jirka Jirout's CarPC Specs
 
Jirka Jirout's Avatar
 
Join Date: Jul 2005
Location: Netherlands
Vehicle: 1993 Tatra 613-4Mi Long
Posts: 540
My Photos: (0)
Not sure about how to do this in AppleScript and Automator or whether it is possible at all, but this thing is relatively easy otherwise. All you need to do is to adjust the gamma of the screen. An example from my code:

Code:
- (void) setNiteVision:(BOOL)niteVisionState { if (niteVisionState){ // engage the nite vision by changing the screen gamma value // the values (which determine the color an brightness) are // taken from the module's setup where they are stored as NSNumbers CGGammaValue gamma, min; CGDisplayErr err; min = 0.1; float redMax = [[moduleSetup objectForKey:@"RED_GAMMA"] floatValue]; float greenMax = [[moduleSetup objectForKey:@"GREEN_GAMMA"] floatValue]; float blueMax = [[moduleSetup objectForKey:@"BLUE_GAMMA"] floatValue]; gamma = 1.0; // we do not want to change the curve, just adjust end points err = CGSetDisplayTransferByFormula( CGMainDisplayID(), min, redMax, 1, // red min, greenMax, 1, // green min, blueMax, 1); // blue } else // restore the default gamma curve as defined in the system // preferences for all displays CGDisplayRestoreColorSyncSettings(); }

Jirka Jirout is offline   Reply With Quote
Old 07-19-2006, 04:53 PM   #5
Maximum Bitrate
pepsibobby's CarPC Specs
 
pepsibobby's Avatar
 
Join Date: Dec 2005
Location: Langley AFB
Vehicle: 2006 Saturn Ion2
Posts: 549
My Photos: (0)
i want the app pease.
__________________
Cant code cause I dont know how, but give me the paint bucket and my eraser and have at you!
pepsibobby is offline   Reply With Quote
Old 07-19-2006, 09:05 PM   #6
Admin
Bugbyte's CarPC Specs
 
Bugbyte's Avatar
 
Join Date: Sep 2004
Location: Corning, NY
Vehicle: 2001 VW Beetle
Posts: 4,413
My Photos: (19)
Following is an Applescript handler that use GUI scripting to control the Display preference pane. I presume if your screen does not have a "Brightness" slider that this script will error. It works fine on my Apple studio display but I haven't tested it on the Xenarc.

Cut and paste the code below the dashes and run it in applescript studio to try it out. If it works, save one Applescript with the dim value and save a different one with the bright value. You should be able to dim/bright by running the appropriate script.

------------------------------------------------------------

ChangeBrightness(.5) --Set this value between 0 and 1 to adjust brightness

on ChangeBrightness(BrightnessValue)

tell application "System Preferences"
--activate
set current pane to pane "com.apple.preference.displays"
end tell
tell application "System Events" to tell process "System Preferences"

tell radio button "Display" of tab group 1 of window 1 to if value is 0 then
repeat until value is 1
click
end repeat
end if


tell slider 1 of group 2 of tab group 1 of window 1 to set value to BrightnessValue
end tell
--tell application "System Preferences" to quit
end ChangeBrightness
__________________
-Where in the world is the iBug?
-Find out about theiBug
-Attention Newbies! Have you seen the FAQ Emporium?
-No time to figure it out? Take 5 minutes to view the Car PC 101 video
Bugbyte is offline   Reply With Quote
Old 07-20-2006, 09:38 PM   #7
Low Bitrate
thanassius's CarPC Specs
 
thanassius's Avatar
 
Join Date: Apr 2006
Location: Maryland
Vehicle: 2000 VW Jetta
Posts: 82
My Photos: (11)
Thanks Bugbyte, I tried it on my Powerbook and it works great! I'll try it on the Mini tomorrow as well. One question though, is there any code that can be added to make everything hidden as it works? Currently you see the Displays pref pane opening and adjusting, and then it remains open when the script has finished running. Can all that be done in the background? Thanks!
thanassius is offline   Reply With Quote
Old 07-21-2006, 03:50 PM   #8
Admin
Bugbyte's CarPC Specs
 
Bugbyte's Avatar
 
Join Date: Sep 2004
Location: Corning, NY
Vehicle: 2001 VW Beetle
Posts: 4,413
My Photos: (19)
I can't quite get every bit of it to be invisible, but here's a script that does it and only shows the display window briefly, then closes the prefs window.

ChangeBrightness(1) --Set this value between 0 and 1 to adjust brightness

on ChangeBrightness(BrightnessValue)

tell application "System Preferences"
launch without visibles
set current pane to pane "com.apple.preference.displays"
end tell
tell application "System Events" to tell process "System Preferences"

tell radio button "Display" of tab group 1 of window 1 to if value is 0 then
repeat until value is 1
click
end repeat
end if
tell slider 1 of group 2 of tab group 1 of window 1 to set value to BrightnessValue
end tell
tell application "System Preferences" to quit
end ChangeBrightness
__________________
-Where in the world is the iBug?
-Find out about theiBug
-Attention Newbies! Have you seen the FAQ Emporium?
-No time to figure it out? Take 5 minutes to view the Car PC 101 video

Last edited by Bugbyte : 07-21-2006 at 04:00 PM.
Bugbyte is offline   Reply With Quote
Old 07-21-2006, 03:58 PM   #9
FLAC
 
shotgunefx's Avatar
 
Join Date: Apr 2005
Location: Boston, MA
Vehicle: 2002 Chrysler Sebring Coupe LXI
Posts: 1,747
My Photos: (30)
Don't know if this is helpful or not, I have a perl script here that's meant to run from cron every X minutes and do something depending on if it's night or day.

The fleshed out version on my system uses xbrightness to change the gamma in X. (Though it checks to see if a net cable is plugged in first, then it acts like it's always day because I'm in the house).

I know OSX is based on BSD, but I know nothing about the windowing system.
shotgunefx is offline   Reply With Quote
Old 07-22-2006, 11:58 AM   #10
Low Bitrate
thanassius's CarPC Specs
 
thanassius's Avatar
 
Join Date: Apr 2006
Location: Maryland
Vehicle: 2000 VW Jetta
Posts: 82
My Photos: (11)
Thanks Bugbyte! The revised code works very well. All that shows is the system prefs window for a second or two, but for my needs that's acceptable. Now I just have to test it on the Mini connected to the Xenarc.

Shotgun, I saved Bug's script as an applicatoin and I'm going to work with automator to run it at specific times of the day, but thanks for your post.
thanassius is offline   Reply With Quote
Sponsored Links
Old 07-22-2006, 12:18 PM   #11
Low Bitrate
thanassius's CarPC Specs
 
thanassius's Avatar
 
Join Date: Apr 2006
Location: Maryland
Vehicle: 2000 VW Jetta
Posts: 82
My Photos: (11)
Ok so nevermind Automator, I resaved them as scripts, then created an event in iCal that repeats everyday at a specified time, and I set the alarm to Run Script. Still ahve to test on the mini though.
thanassius is offline   Reply With Quote
Old 03-17-2007, 02:35 AM   #12
Low Bitrate
thanassius's CarPC Specs
 
thanassius's Avatar
 
Join Date: Apr 2006
Location: Maryland
Vehicle: 2000 VW Jetta
Posts: 82
My Photos: (11)
I'm about to resurrect an old thread, in hopes of putting it to bed for good! I took my install off of the indefinite hold it's been on for almost a year, and I just had some new thoughts on this issue...

Bugbyte's AppleScripts mentioned above work great for an Apple notebook or cinema display, but unfortunatly have no effect on the touchscreens most of us are using. However, using Shades, you can adjust the screen brightness of any display connected to any Mac, as the adjustment is not dependant on any specific type of hardware. It also has the ability to assign hot keys to increase and decrease brightness functions.

As I mentioned earlier, I have no coding skills at all, SO, would someone be willing to write up an AppleScript similar to Bugbyte's that opens Shades (if its not already running) and sends the hot key combinations to it? Shades can run hidden in the background (in its preferences, keep it out of the dock and the menu bar), and we can set the resulting Apple Script as a reccuring iCal alarm, to seamlessly automate the process of dimming and brightening our touchscreens at predetermined times of the day.

I would be totally thrilled if someone would be able to do this! Thanks in advance :-)

Last edited by thanassius : 03-17-2007 at 02:41 AM. Reason: clarifying a bit
thanassius is offline   Reply With Quote
Old 03-17-2007, 02:23 PM   #13
Admin
Bugbyte's CarPC Specs
 
Bugbyte's Avatar
 
Join Date: Sep 2004
Location: Corning, NY
Vehicle: 2001 VW Beetle
Posts: 4,413
My Photos: (19)
I suggested this idea in the Amp wishlist thread but I don't think people took it seriously. I like this implementation. It should be a snap to write a script.

For awhile, I looked into trying to calculate sunrise/sunset based on a user's lat/long but Applescript doesn't have the math functions to do it. You end up having to call them out of Coccoa! The iCal alarm idea is a dead simple solution for that problem.

I'll look at it but no promises on time frames.
__________________
-Where in the world is the iBug?
-Find out about theiBug
-Attention Newbies! Have you seen the FAQ Emporium?
-No time to figure it out? Take 5 minutes to view the Car PC 101 video
Bugbyte is offline   Reply With Quote
Old 03-17-2007, 03:17 PM   #14
QCar Creator
Jirka Jirout's CarPC Specs
 
Jirka Jirout's Avatar
 
Join Date: Jul 2005
Location: Netherlands
Vehicle: 1993 Tatra 613-4Mi Long
Posts: 540
My Photos: (0)
http://www.srrb.noaa.gov/highlights/sunrise/azel.html

Check the source of the page for JavaScript implementation of the algorithm that calculates the position of sun. And I am sure there are plenty of other sites and libraries. AFAIK it does not require any math, that is not doable in AppleScript.
Jirka Jirout is offline   Reply With Quote
Old 03-17-2007, 03:22 PM   #15
Admin
Bugbyte's CarPC Specs
 
Bugbyte's Avatar
 
Join Date: Sep 2004
Location: Corning, NY
Vehicle: 2001 VW Beetle
Posts: 4,413
My Photos: (19)
Try this

This worked on my Mini with Shades installed.

There's no error handling in it. It assumes Shades is running. It then checks to see if it is either before or after 12:00pm. If it is after 12:00pm, it dims. If it is before 12:00pm, it brightens.

It sends 10 repeats of Cmd and '-' or 10 repeats of Cmd and '+'. Make sure your hotkeys are set to this setting.

You can easily modify how many times it repeats by opening the script in Script Editor and changing the number in the "repeat" lines. There are two.
Attached Files
File Type: zip ShadesDimmer.zip (19.1 KB, 47 views)
__________________
-Where in the world is the iBug?
-Find out about theiBug
-Attention Newbies! Have you seen the FAQ Emporium?
-No time to figure it out? Take 5 minutes to view the Car PC 101 video
Bugbyte is offline   Reply With Quote
Sponsored Links
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Touch Screen Based Gesture Interface? Lazyflip Software & Software Development 13 01-25-2006 02:28 PM
Dim LCD based on ambient light neon_eddy LCD/Display 3 12-01-2005 07:02 AM
Request: Time based gamma control. TRONiC Centrafuse 2 09-20-2005 07:16 PM
FS: DWW-7VGA 7" Touch Screen VGA LCD * Based on the Xenarc/Gain 7" VGA LCD faichiu Classified Archive 6 10-20-2004 02:30 AM
Problems with screen backlight and allen controller setup MikeHunt79 LCD/Display 13 07-02-2002 10:54 AM


All times are GMT -5. The time now is 06:02 AM.


Sponsored Links
The MP3car.com Store

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.1.0
Copyright © 1999 - 2008 Mp3Car.com Inc.
Ad Management by RedTyger
Message Board Statistics