Re: Get and set "Auto adjust brightness when ambient light changes" preferences
Re: Get and set "Auto adjust brightness when ambient light changes" preferences
- Subject: Re: Get and set "Auto adjust brightness when ambient light changes" preferences
- From: Gabriel ROUSSEAU <email@hidden>
- Date: Tue, 3 Jun 2008 23:36:51 +0200
BezelServices does what you say, but not only !
It seems to also manage the ALS preferences. In the
com.apple.BezelServices.plist you can see preferences concerning ALS
behavior on the keyboard backlight and the display brightness, like :
– alsLGPVersion
– dAuto (display auto birghtness from ALS, the pref I would like to
change)
– kAuto (keybloard backlight from ALS)
and there is also values for the ALS change brightness fade speed, etc…
I know that that should not be in Bezel, but Apple seems to have put
this here. DisplayServices would be a more logical choice, but Apple
might have their reasons, maybe it was simpler because some code is
here for the keyboard brightness commands.
Also, when I am Sampling SystemPreferences, when changing the "Auto-
adjust brightness when ambient light is changing", it deals with
BezelServices, but it has noting to do with visual display
notifications (no feedback, and there is not any key or key
combination to change this preference but this checkbox in the Display
tab of SystemPreferences).
Moreover, another clue is that some methods in BezelServices are
things like "ambientFeatureAvailable" "setKeyboardValue" (to set up
backlight value), "setDisplayValue" (to set up brightness value).
So BezelServices is not only related to visual feedback, but more like
a controller.
As I said, there is a BezelServices plugin that resides in the
loginwindow process (that is always running), and that process is
firing regularly timers to listen to the sensors and detect ambient
light changes, and the BezelServices Framework is dealing with this
plugin. Try to sample loginwindow on a MacBook Pro and just change
ambient light, you will see that it reacts. Also, when changing the
auto-adjust brightness when ambient light is changing in
SystemPreferences, there is related activity in loginwindow an
evidence that it is this loginwindow plugin that is dealing with ALS
auto-adjust feature on or off.
It is so complex to simply change one boolean value !
SystemPreferences is able to change this value, me no, and the only
way is to deal with BezelServicesWireProtocol, but I do not know what
it is or how to invoke the object having this protocol.
SystemPreferences is not scriptable for that feature too. That wold
have been a solution to remote setup this preference.
Le 3 juin 08 à 21:11, Jean-Daniel Dupas a écrit :
BezelServices is not used to control ALS but to display visual
notification like the one you see when you change the audio volume,
or when you press the eject key.
Le 3 juin 08 à 20:58, Gabriel ROUSSEAU a écrit :
Hi,
There is one thing that should be accessible from UserDefaults or
by AppleScript, or some kind of CGDisplay or NSScreen methods, but
it is not the case.
On MacBooks Pro and PowerBooks (don't know for MacBooks and
iBooks), there is a feature called ALS (Ambient Light Sensors) in
the hardware. The computer know the ambint light level.
Thats cool, and it is used to automatically adjust keyboard
backlight and display brigthness. In System Preferences theses
features can be enabled or disabled.
I will concentrate on the Display side : In System Preferences, in
the Display Tab, there is a way to activate or deactivate the
feature. Great, but wait a minute ! It is the ONLY way to activate
or deactivate it !
No way to AppleScript this, no way to do this using defaults, no
way to change it programatically.
Why ? Because in fact, this feature is managed by a loginwindow
plugin called BezelServices.loginPlugin that resides in /System/
Library/LoginPlugins/
It seems that SystemPreferences is using a PrivateFramework to
communicate with loginwindow ; this Framework is called
"BezelServices.Framework".
Of course, since this is a private Framework, no way to activate or
deactivate ALS officialy, and it means no support, no
documentation :-(
I have managed to have some more info using classdump, Instruments
developer tool, but I am stuck. Here are all the info I have found :
– The BezelServices.plist preference file is only read and write at
startup and shutdown, or probably User session starting and
stopping. Thats means trying to change values in this plist are
useless.
– The BezelServices.Framework can be classdumped, here is the dump :
----------
/*
* Generated by class-dump 3.1.2.
*
* class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2007
by Steve Nygard.
*/
#include "CDStructures.h"
@class NSMutableDictionary;
@interface BSFWClient : NSObject
{
NSMutableDictionary *addCall; // 4 = 0x4
// struct ProcessSerialNumber _process; // 8 = 0x8
}
- (id)init;
- (void)dealloc;
- (short)addCallback:(void *)fp8 ForType:(unsigned long)fp12;
- (short)removeCallbackForType:(unsigned long)fp8;
- (int)callbackCount;
- (BOOL)isValidEventType:(unsigned long)fp8;
- (unsigned short)handleBSProxyEvent:(CDAnonymousStruct1)fp8;
@end
----------
/*
* Generated by class-dump 3.1.2.
*
* class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2007
by Steve Nygard.
*/
/*
struct ProcessSerialNumber {
unsigned int highLongOfPSN;
unsigned int lowLongOfPSN;
};
*/
typedef struct {
unsigned int _field1;
unsigned int _field2;
unsigned int _field3;
unsigned int _field4[6];
} CDAnonymousStruct1;
-----------
/*
* Generated by class-dump 3.1.2.
*
* class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2007
by Steve Nygard.
*/
@protocol BezelServicesWireProtocol
- (BOOL)registerProxyClient:(id)fp8 ForProcess:(id)fp12;
- (BOOL)unregisterProxyClientForProcess:(id)fp8;
- (id)preference;
- (int)setPreference:(id)fp8;
- (id)objectForPrefKey:(id)fp8;
- (int)setObject:(id)fp8 forPrefKey:(id)fp12;
- (int)ambientFeatureAvailable;
- (int)isKeyboardSaturated:(int *)fp8;
- (void)setKeyboardHold:(int)fp8;
- (void)setDisplayHold:(int)fp8;
- (void)setKeyboardValue:(float)fp8;
- (void)setDisplayValue:(float)fp8;
- (void)kernelPreferenceChanged:(id)fp8;
- (void)kernelPreferenceCreate:(id)fp8 ResetToDefaults:(BOOL)fp12;
- (int)remoteControlFeatureAvailable;
- (void)remoteUIToggle;
- (void)handleRemoteEventWithPage:(unsigned short)fp8 usage:
(unsigned short)fp12 flags:(unsigned short)fp16 value:(long)fp20;
@end
-----------
Interesting, we can see that the BezelServicesWireProtocol is what
we need ! But wait, what object conforms to this protocol ? How to
get an instance ? What the hell is a WireProtocol ?
To have an idea, I have used Instruments to sample
SystemPreferences exactly when I click the checkbox to change the
ALS setting, and I have found this :
Library Symbol Name
...
AppKit -[NSApplication sendAction:to:from:]
Brightness 0x1667f01a
BezelServices BSSetPreferenceBool
CoreFoundation _CF_forwarding_prep_0
...
Very interesting, whe have a BezelServices Framework object using
BSSetPreferenceBool ! Exactly what I want, but I don't know the
Class of this object, the way to instantiate it, etc… I am still
stuck.
What is this "Brightness" library ? Another Private Framework ? I
am lost at this point.
So, if someone have an idea, that would be kind. The only tihng I
want to do is activate or deactivate this ALS setting. I am not
really insterested in the reverse engineering challenge or anything
like that, only to find a way to activate or deactivate this ALS
thing from my code.
Regards._______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden