pulsar-mouse: make the per-state widget colors configurable (#336)
* pulsar-mouse: make the per-state widget colors configurable Both widgets hardcoded their state colors: error for a fault, secondary while charging, error at the mouse's low-power threshold. The desktop widget's one `color` setting only covered the normal state, and the bar widget had no color setting at all. Expose all four states (normal/charging/low/error) as `type = "color"` settings on each widget, in the same shape battery-widget uses. Defaults reproduce exactly what was hardcoded, so an existing install renders identically until someone changes one. The new settings are `advanced`; the desktop widget's pre-existing `color` stays where it was so it does not disappear behind the toggle for anyone already using it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * pulsar-mouse: rename the bar's normal-state key to normal_color A bar widget's plugin settings share one TOML table with Noctalia's own per-widget presentation settings, where `color` already exists ("Color role for this widget's icon and label"). A plugin declaring `color` there does not shadow it, it aliases it - one `color = "primary"` under [widget.<id>] drove both pickers at once, so setting either silently moved the other. Renamed to `normal_color`, which also makes the retest unambiguous: the glyph follows the plugin setting while Presentation's own Color picker stays on Default. The desktop widget keeps plain `color` - no clash there, and renaming it would break existing configs. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
a7581e8a1c
commit
13bde174ad
@@ -25,6 +25,11 @@ local LOW_POWER_DEFAULT = 15 -- used when the driver has no low-power-threshold
|
||||
-- getter (e.g. nordic.py) or it hasn't been read yet
|
||||
|
||||
local color = noctalia.getConfig("color")
|
||||
-- The other three states. Defaulted in plugin.toml to the values these were
|
||||
-- previously hardcoded to, so an existing install renders identically.
|
||||
local chargingColor = noctalia.getConfig("charging_color")
|
||||
local warningColor = noctalia.getConfig("warning_color")
|
||||
local errorColor = noctalia.getConfig("error_color")
|
||||
local showProgress = noctalia.getConfig("show_progress")
|
||||
local showPercent = noctalia.getConfig("show_percent")
|
||||
local glyphSize = noctalia.getConfig("glyph_size")
|
||||
@@ -38,13 +43,13 @@ local checkingCli = false
|
||||
|
||||
local function statusColor()
|
||||
if errorText ~= nil then
|
||||
return "error"
|
||||
return errorColor
|
||||
end
|
||||
if charging then
|
||||
return "secondary"
|
||||
return chargingColor
|
||||
end
|
||||
if percent ~= nil and percent <= (lowPowerThreshold or LOW_POWER_DEFAULT) then
|
||||
return "error"
|
||||
return warningColor
|
||||
end
|
||||
return color
|
||||
end
|
||||
@@ -77,7 +82,7 @@ local function render()
|
||||
if errorText ~= nil then
|
||||
-- Diagnostic, not decorative - stays visible even with show_percent off,
|
||||
-- since otherwise a broken setup would just silently show a bare glyph.
|
||||
table.insert(rows, ui.label({ key = "status", text = errorText, fontSize = 12, color = "error" }))
|
||||
table.insert(rows, ui.label({ key = "status", text = errorText, fontSize = 12, color = errorColor }))
|
||||
elseif showPercent and percent == nil then
|
||||
table.insert(rows, ui.label({ key = "status", text = "--", fontSize = 20, color = "outline" }))
|
||||
elseif showPercent then
|
||||
|
||||
Reference in New Issue
Block a user