fix: bar widget render guard, capability-gated scroll, sidetone rollback

This commit is contained in:
loki committed 2026-08-31 12:31:44 +02:00
1 parent 1011d43b2e
commit 96bf267937
1 file changed
+9
+9
View File
@@ -33,6 +33,7 @@ local function batteryColor()
end
local function render()
if not barWidget then return end
if errorState == "no_binary" then
barWidget.setGlyph("alert-triangle")
barWidget.setColor("#e5484d")
@@ -76,8 +77,14 @@ end
local function sendSidetone(value)
value = math.clamp(value, 0, 128)
local previous = sidetoneValue
hsc.sendCommand({ "-s", tostring(value) }, function(res)
if res.exitCode ~= 0 then
if previous ~= nil then
sidetoneValue = previous
end
sidetoneFlashUntil = 0
render()
noctalia.notifyError(noctalia.tr("error.command_failed"), string.sub(res.stderr or "", 1, 200))
return
end
@@ -90,6 +97,7 @@ end
function onScroll(axis, steps)
if axis ~= "vertical" then return end
if not caps.sidetone or errorState ~= "" then return end
local current = sidetoneValue or noctalia.getConfig("sidetone_default") or 64
sendSidetone(current + steps * 4)
end
@@ -126,3 +134,4 @@ noctalia.state.watch("error", function(v) errorState = v or ""; render() end)
noctalia.state.watch("sidetone", function(v) if v ~= nil then sidetoneValue = v end end)
syncState()
render()