nathanbabcock / nightlight-cli

Control Windows 10/11's Night Light feature programmatically πŸŒ“
20 stars 2 forks source link

Night Light CLI πŸŒ“

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.

Compatibility

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.

Contribution

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

Getting started (TypeScript)

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())

Getting started (CLI)

npm i -g nightlight-cli
nightlight toggle

...or...

npx nightlight-cli toggle