Skip to content

Add panel sensor selector to preferences#572

Open
samirhvbr wants to merge 1 commit into
corecoding:developfrom
samirhvbr:panel-sensor-selector
Open

Add panel sensor selector to preferences#572
samirhvbr wants to merge 1 commit into
corecoding:developfrom
samirhvbr:panel-sensor-selector

Conversation

@samirhvbr

Copy link
Copy Markdown

Summary

Adds a new Panel page to the extension preferences that lists every sensor Vitals has discovered, grouped by category, each with a switch to show or hide it in the top bar.

Today the only way to change which sensors appear in the panel is to open the Vitals dropdown menu and toggle them one at a time. This makes that selection discoverable and manageable directly from the preferences window.

What changed

  • prefs.js — New Panel page (_buildPanelSensorsPage). It reads the discovered sensors, buckets them by category, and renders one Adw.SwitchRow per sensor. Toggling a row adds/removes that sensor from the hot-sensors setting (the list the panel renders). The existing _default_icon_ placeholder invariant is preserved (shown only when nothing else is selected). The pre-existing, first page is now titled General.
  • extension.js — As sensors are discovered they are recorded and published to a new available-sensors setting so the preferences window (a separate process) can build the list. A changed::hot-sensors handler redraws the panel when the selection changes from the new page.
  • schemas/…gschema.xml — New available-sensors key (JSON string) used to hand the discovered-sensor list to the preferences process.

How it works

prefs and the running extension are separate processes, so they communicate through GSettings:

  1. The extension discovers sensors during its normal polling and writes a stable, de-duplicated JSON list to available-sensors.
  2. The preferences window reads that key, builds the switches, and rebuilds them on changed::available-sensors when new sensors appear.
  3. Flipping a switch writes hot-sensors; both the panel and the switches listen for changed::hot-sensors and stay in sync, with a guard against feedback loops. Comparing the desired vs. shown sets keeps the panel redraw timing-independent.

Notes

  • If the Vitals menu has not been opened yet, no sensors have been discovered, so the page shows a short hint asking the user to open the menu once; the sensors then appear automatically.
  • The preferences signal handlers are disconnected on the window's close-request to avoid leaks.

How to test

  1. Enable the extension and open the Vitals menu once so sensors are discovered.
  2. Open preferences → Panel. Every discovered sensor is listed, grouped by category.
  3. Toggle a switch off/on and confirm the sensor disappears from / reappears in the top bar.
  4. Toggle sensors from the dropdown menu and confirm the switches update to match.
  5. Turn every sensor off and confirm the panel falls back to the placeholder icon.

- New "Panel" page in preferences lists every sensor the extension has
  discovered, grouped by category, each with a switch that toggles its
  visibility in the top bar (writes hot-sensors). Sensor selection no
  longer requires hunting through the dropdown menu.
- extension.js publishes discovered sensors via a new `available-sensors`
  setting so the (separate) prefs process can build that list, and redraws
  the panel when hot-sensors changes from the selector.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant