Files
omarchycn/shell/plugins/services/nightlight/NightlightModel.js
T
David Heinemeier HanssonandClaude Fable 5 ba91bad3a4 Move Night Light onto a first-party nightlight service
Same treatment as Stay Awake: the indicator polled the toggle CLI over
a Process with a timer to paper over the race after clicking, and the
CLI ended by asking the shell to refresh every indicator over IPC. A new
omarchy.nightlight service owns hyprsunset instead - it probes the
temperature on startup, applies changes itself for in-shell toggles, and
answers on the nightlight IPC target. The indicator becomes a plain
binding. The CLI still drives hyprctl directly so keybindings, the menu,
and ssh work without the shell, but now just nudges the service to
re-probe since hyprsunset has no state file to watch.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-21 15:26:20 -07:00

21 lines
689 B
JavaScript

// Temperatures below the identity point count as night light. Keep in sync
// with bin/omarchy-toggle-nightlight, which applies the same threshold.
var IDENTITY_TEMPERATURE = 6000
function temperatureFromOutput(output) {
var match = String(output === undefined || output === null ? "" : output).match(/[0-9]+/)
return match ? Number(match[0]) : null
}
function isNightlight(temperature) {
return temperature !== null && temperature !== undefined && temperature < IDENTITY_TEMPERATURE
}
if (typeof module !== "undefined") {
module.exports = {
IDENTITY_TEMPERATURE: IDENTITY_TEMPERATURE,
temperatureFromOutput: temperatureFromOutput,
isNightlight: isNightlight
}
}