I have a problem. I have two keyboard layouts in my Mac because I have to type in two different languages while communicating with different people. I use the keyboard shortcut Cmd+Space
to switch from one layout (language) to another.
I wonder if I can run custom script when Cmd+Space
is pressed? I know there is an app called Punto Switcher that can do that.
My idea is to change keyboard highlighting level to indicate current language.
The question is where to find API that can
Neat pointer to the LED brightness stuff from @Anoop Vaidya -- looks interesting!
The system sends a notification when the input method changes.
First, declare a function to receive the notification:
void theKeyboardChanged(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
NSLog(@"Keyboard/input method changed.");
}
Then register for the change notification:
CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(),
myContextInfo, theKeyboardChanged,
kTISNotifySelectedKeyboardInputSourceChanged, NULL,
CFNotificationSuspensionBehaviorDeliverImmediately);
I found a blog of Amit Singh, where he gave idea as in undocumented APIs , he used C, for this, you can surely find some sort of help from this.
Experimenting With Light.
Or you can try with these codes:
UInt64 lightInsideGetLEDBrightness(){
kern_return_t kr = 0;
IOItemCount scalarInputCount = 1;
IOItemCount scalarOutputCount = 1;
UInt64 in_unknown = 0, out_brightness;
kr = IOConnectCallScalarMethod(dataPort, kGetLEDBrightnessID, &in_unknown, scalarInputCount, &out_brightness, &scalarOutputCount);
return out_brightness;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With