Mac OS X: Changing the Pickup Keyboard Layout

I have a problem. I have two keyboard layouts on my Mac, because I have to enter two different languages, exchanging information with different people. I use the Cmd+Space keyboard shortcut to switch from one layout (language) to another.

I wonder if I can run a custom script when I press Cmd+Space ? I know there is an app called Punto Switcher that can do this.

My idea is to change the keyboard backlight level to indicate the current language.

  • Bright = German (or Russian or any other)
  • Dim = english

The question is where to find an API that can

  • intercept keyboard layout in Mac OS X
  • change the brightness of the keyboard backlight

enter image description here

+6
source share
2 answers

A neat pointer to the material brightness LEDs from @Anoop Vaidya - looks interesting!

The system sends a notification when the input method changes.

First declare a function to receive a notification:

 void theKeyboardChanged(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { NSLog(@"Keyboard/input method changed."); } 

Then register for a change notification:

 CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(), myContextInfo, theKeyboardChanged, kTISNotifySelectedKeyboardInputSourceChanged, NULL, CFNotificationSuspensionBehaviorDeliverImmediately); 
+5
source

I found Amit Singh's blog, where he gave the idea how, in undocumented APIs, he used C, for this you will surely find some 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; } 
+1
source

All Articles