Control Windows 10/11's Night Light feature programmatically.
The binary format of the registry value was reverse engineered from
NightLight.cs
in the tiny-screen
project
by Maclay74, and converted to Typescript with
help from ChatGPT.
For changing the scheduled Night Light settings via a slightly different registry key, see this post: https://superuser.com/a/1209192.
Windows Version | Status |
---|---|
Windows 11 22H2 | β Tested |
Windows 10 21H2 | β Untested but should work |
Please open an issue if you find that this package does not work on your version of Windows.
Since this works by modifying a single registry key, it can be done in any language. A few examples are implemented already.
Language | Status |
---|---|
TypeScript | β |
CLI (NodeJS) | β |
C# | β¬οΈ upstream |
Python | βοΈ Open a PR |
Rust | βοΈ Open a PR |
Powershell | βοΈ Open a PR |
Other | βοΈ Open a PR |
const nightLight = new NightLight()
console.log('Supported:', nightLight.supported())
console.log('Enabled:', await nightLight.enabled())
console.log('Toggling')
await nightLight.toggle()
console.log('Enabled:', await nightLight.enabled())
npm i -g nightlight-cli
nightlight toggle
...or...
npx nightlight-cli toggle