Welcome to the Power Users community on Codidact!
Power Users is a Q&A site for questions about the usage of computer software and hardware. We are still a small site and would like to grow, so please consider joining our community. We are looking forward to your questions and answers; they are the building blocks of a repository of knowledge we are building together.
Programmatically changing the keyboard illumination in small steps
Background story:
I would like to have a button in my touch bar which changes the illumination of the keyboard in small steps (what you normally get from pressing Illumination(up/down)
+option
+shift
).
To do this I'm currently trying to use MTMR (My touchbar. My rules.), which allows me to create my own buttons, which then can run shell scripts, apple scripts, etc.
For the screen brightness I can easily get my desired behaviour by this apple script:
tell application "System Events" to key code 107 using {option down, shift down}
However for the illumination key, there does not seem to be a key code which I can use in the apple script. Is there any other way to change the keyboard illumination programmatically?
(If possible, I would like to use open source tools and avoid commercial software like BetterTouchTools)
1 answer
Instead of trying to build my own touch bar, I'm now using Karabiner Elements to remap the existing keys on the touchbar to the desired behaviour.
The following configuration will remap the screen brightness, keyboard illumination and volume keys to change their settings in small increments:
{
"description": "Touchbar small increments",
"manipulators": [
{
"from": {
"apple_vendor_top_case_key_code": "brightness_down"
},
"to": [
{
"key_code": "display_brightness_decrement",
"modifiers": [
"left_shift",
"left_option"
]
}
],
"type": "basic"
},
{
"from": {
"apple_vendor_top_case_key_code": "brightness_up"
},
"to": [
{
"key_code": "display_brightness_increment",
"modifiers": [
"left_shift",
"left_option"
]
}
],
"type": "basic"
},
{
"from": {
"apple_vendor_top_case_key_code": "illumination_down"
},
"to": [
{
"key_code": "illumination_decrement",
"modifiers": [
"left_shift",
"left_option"
]
}
],
"type": "basic"
},
{
"from": {
"apple_vendor_top_case_key_code": "illumination_up"
},
"to": [
{
"key_code": "illumination_increment",
"modifiers": [
"left_shift",
"left_option"
]
}
],
"type": "basic"
},
{
"from": {
"consumer_key_code": "volume_decrement"
},
"to": [
{
"key_code": "volume_decrement",
"modifiers": [
"left_shift",
"left_option"
]
}
],
"type": "basic"
},
{
"from": {
"consumer_key_code": "volume_increment"
},
"to": [
{
"key_code": "volume_increment",
"modifiers": [
"left_shift",
"left_option"
]
}
],
"type": "basic"
}
]
}
0 comment threads