Keyboard Backlight Brightness Touchbar Slider

After a ton of hacking, I finally figured out a way to implement a slider for keyboard backlight illumination that is roughly consistent with the out if the box volume and screen brightness slider widgets.

The implementation takes the form of a custom applescript slider that triggers two other (hidden) buttons that take advantage of the single step up/down in backlight brightness. The slider will first set the keyboard brightness and slider position to 0, and then poll on slider movement to see if the slider is "ahead" or "behind" of the brightness we set under the hood with our buttons, step by step.

First you'll need to create two simple Keyboard Illumination Up/Down buttons. One of each. Make sure they work, but then uncheck their visible checkboxes as they wont be needed when the slider is in place.

Right click each of them and click "Copy UUID (for use with Applescript)" Toss them in a text doc or something for quick reference in a moment.

Create a custom applescript slider. The initial applescript will just dim the brightness all the way (16 times is the max) and set the slider value to 0, to harmonize the brightness and slider values. The applescript to enter under the "custom configuration" option of the slider is:

tell application "BetterTouchTool"
set_number_variable "current" to 0
repeat 16 times
	execute_assigned_actions_for_trigger "AE1FCD12-E8A2-418C-810D-838951526320"
end repeat
end tell
return 0.0

Replace the UUID in this code with the uuid of the button that DIMS the backlight by one step.

Set the predefined action to "Run Applescript (async)", and enter the following applescript.

on bttWidgetSliderMoved(sliderValue)
tell application "BetterTouchTool"
	set slider to round (sliderValue * 16)
	set current to round (get_number_variable "current")
	if slider > current then
		set num to slider - current
		repeat num times
			execute_assigned_actions_for_trigger "D9DB3A67-E6A0-49B3-8433-CB0D7540D08C"
		end repeat
		set_number_variable "current" to current + num
	else if slider < current then
		set num to current - slider
		repeat num times
			execute_assigned_actions_for_trigger "AE1FCD12-E8A2-418C-810D-838951526320"
		end repeat
		set_number_variable "current" to current - num
	end if
end tell
end bttWidgetSliderMoved

Again, replace the second uuid listed with the uuid of the button that dims the backlight, but replace the first uuid listed with the one that raises it. you may also choose to use some globally defined ids, but i didn't.

This should give you a roughly consistent keyboard backlight slider. You can also chose to have the default value be something other than 0 / no brightness by editing the initial configuration. Reply with any questions or clarifications and I'm happy to reply with guidance if possible, and all feedback is of course appreciated.

Hi,

what do you mean with "..but replace the first uuid listed with the one that raises it". I copied the UUID of the slider and replaced the second UUID (AE1...). But which UUID do I have to use for the first?

Thank you in advance for your help!

Best regards

Hey Joe - for the second code block - there are two UUIDs that you'll have to swap out. The first uuid is for the button that raises the backlight, and the second uuid is for the button that dims it. These are created in the earlier step:

"First you'll need to create two simple Keyboard Illumination Up/Down buttons. One of each. Make sure they work, but then uncheck their visible checkboxes as they wont be needed when the slider is in place."

Does this make sense?

Great work, William! Really glad to have a working slider for this. It's a bit laggy, and I really wish it was an out of the box widget, but I'm not complaining--just happy. Thanks!

Can someone please explain how to implement this on the latest version of BetterTouchTool? It doesn’t seem to be working for me. The backlight is always on and the slider doesn’t do anything.

Ridiculous that the developer of BetterTouchTool has decided this workaround is acceptable rather than actually implementing an often-requested feature that comes standard on the default touch bar...

Hi guys, I'm having the same problem (this doesn't seem to do anything with BTT current version).

Can anyone chime in and let me know if this is still working?

Looks like I figured it out - problem is that external BTT scripting needs to be turned on. See post #8 here: