[Sharing] Slider for Night Shift

Hi all,

Here's a night shift slider preset that I'd like to share, you can use it to change the strength (color) of night shift.

Tap the icon to toggle Night Shift


Hold the icon to bring up the slider, you can also see the current color temperature of your screen on the right.


This preset is achieved by using apple's private framework CoreBrightness in AppleScript-ObjC, for the one who's only interested in the code, refer to the source folder in my repo: https://github.com/noonchen/BTT_NightShiftSlider, I'm hoping my preset can give you guys some ideas to create amazing presets/widgets.

For users:
NightShiftSlider.bttpreset (100.2 KB)

very cool!

1 Like

Edit: I underestimated my ability to suss out the the problem. I opened up the scripted action, and changed the ns(.5) to ns(.9) and it works now. Excellent to include the slider!

When I use this, toggling it on it always defaults to the center color temperature of 4100 K. Is there a way to edit that? I have my system set to enable night shift much warmer than that, but it doesn't work with this as a trigger.

:laughing: Thanks for your feedback! I'm thinking about storing the strength to a BTT variable when toggling it off, so that we don't have to adjust the slider everytime we turn it on.

thanks for sharing, i added script to macOS Control Center - MCC with little modification

Night Shift Toggle Script

use framework "CoreBrightness"
property cOBJ : a reference to current application's CBBlueLightClient's alloc's init
if ( item 2 of item 2 of (cOBJ's getBlueLightStatus:( reference )) as boolean ) then
cOBJ's setEnabled:(1 = 0)
else
cOBJ's setStrength:0.5 commit: true -- Change this for tempeture between 0 and 1
cOBJ's setEnabled:(0 = 0)
end if

My pleasure :grinning:

thanks very much for this cool little addition :smiley:

Hey Kevin, did you manage to fix that?

I really want to use this but having the same issue and an additional one: even though I disabled schedules on macOS's settings, after a while sometimes temperature will randomly reset back to normal, which is quite annoying. Thanks!

Imprint | Privacy Policy