Skip to content

feat(system): make night light settings-driven - #10

Merged
mirkobrombin merged 1 commit into
singularityos-lab:mainfrom
mateoalfaro:main
Aug 18, 2026
Merged

feat(system): make night light settings-driven#10
mirkobrombin merged 1 commit into
singularityos-lab:mainfrom
mateoalfaro:main

Conversation

@mateoalfaro

@mateoalfaro mateoalfaro commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Reworks NightLightManager from a hard-coded 4000 K on/off toggle into a passive, settings-driven state machine backed by the dev.sinty.desktop schema.

  • Adds a master switch, configurable temperature clamped to 1000–6500 K, and an optional adaptive schedule using HH:MM start/end times.

  • Effective state is:

    enabled && (!adaptive || is_night())
    

    enabled now reflects the effective state rather than the raw switch.

  • Every settings change triggers refresh(), which:

    • Re-applies the backend only when the state or temperature actually changes.
    • Emits changed() on effective-state changes.
    • Re-arms a Timeout for the next schedule boundary.
    • Handles overnight spans.
    • Treats from == to as never night.
  • toggle() and the new setters only write settings; propagation happens through the settings.changed signal.

The GammaBackend interface and singleton are unchanged, and no other code calls the removed enable() / disable() methods.

Tested on

  • NixOS
  • Fedora 44

Refactored NightLightManager to read from settings and support
automatic activation/deactivation based on a configurable time window.
@perlowja

Copy link
Copy Markdown
Contributor

Heads up — this rework reads five GSettings keys that do not exist in the schema, which hard-crashes the shell (SIGABRT) the first time the sidebar is opened.

`NightLightManager` now reads `night-light-enabled`, `night-light-adaptive`, `night-light-temperature`, `night-light-adaptive-from` and `night-light-adaptive-to`, but none of them are defined in dev.sinty.desktop.gschema.xml (which lives in the singularity-desktop supertree, data/). GSettings aborts the process on an unknown key, so SystemMonitor.get_night_light() kills the shell as soon as Sidebar is lazily constructed — i.e. on the first click on the panel.

Measured on a CIX Sky1 board (Radxa Orion O6N) 2026-08-17, via systemd-coredump:

#16 singularity_system_monitor_get_night_light
#17 singularity_system_view_construct
#18 singularity_sidebar_construct
...  g_signal_emit ...
#61 main
Process ... terminated abnormally with signal 6/ABRT

It then crash-loops, because the supervisor restarts the shell and the next sidebar construction aborts again.

I hit this because I merged this branch locally to unblock an unrelated build (singularity-shell main already calls set_schedule_from/set_temperature/TEMP_MIN/TEMP_MAX, so the shell does not build without this PR). Fixed on our side by adding the five keys to the schema — singularityos-lab/singularity-desktop 2e862db — with defaults matching the previous hard-coded behaviour (off, 4000 K), so it is behaviour-preserving. Happy to open that as a PR against singularity-desktop if you would rather it land alongside this one.

Same failure class as the window-border-width / tiling-spacing keys already called out in that schema file, if you want prior art for the fix shape.

@mateoalfaro

mateoalfaro commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

Hey, I am confused about this report as the schema additions have been merged upstream into singularityos-lab/singularity-desktop@4a69ba2 did your local build have the latest version of that repo?

@mirkobrombin
mirkobrombin merged commit 7196e59 into singularityos-lab:main Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants