* feat(battery-threshold): add translations and rule file * feat(battery-threshold): add setup script * feat(battery-threshold): add plugin manifest * feat(battery-threshold): implement battery-threshold service * feat(battery-threshold): implement battery-threshold widget * feat(battery-threshold): implement battery-threshold panel * feat(battery-threshold): add readme * chore(battery-threshold): add dependencies field * chore(battery-threshold): add thumbnail * docs(battery-threshold): add thumbnail to readme * fix(battery-threshold): add thumbnail from generator * chore(battery-threshold): add license and icon fields to plugin.toml * style(battery-threshold): replace tabs with spaces * style(battery-threshold): unflatten translation files * refactor(battery-threshold): use translations for widget tooltip * chore(battery-threshold): replace raw strings with translations * chore(battery-threshold): remove panel ipc event * chore(battery-threshold): check error on file read * chore(battery-threshold): remove `setUpdateInterval` calls * style(battery-threshold): fix formatting * chore(battery-threshold): remove tags capital letters * Update plugin.toml * chore(battery-threshold): remove de fr and tr translations * chore(battery-threshold): update thumbnail * fix(battery-threshold): add shell quoting for runAsync * chore(battery-threshold): embed rule file content in setup script * chore(battery-threshold): update manifest * refactor(battery-threshold): use noctalia.pluginDataDir, log read/write errors * docs(battery-threshold): update README to match template * chore(battery-threshold): add missing dependencies to manifest --------- Co-authored-by: Lemmy <studio@quadbyte.net>
36 lines
1.1 KiB
Luau
36 lines
1.1 KiB
Luau
--!nonstrict
|
|
local function render_widget()
|
|
local is_available = noctalia.state.get("is_available") == true
|
|
local threshold = noctalia.state.get("current_threshold") or 0
|
|
|
|
local container = barWidget.isVertical() and ui.column or ui.row
|
|
|
|
if is_available then
|
|
barWidget.render(container({ gap = 4, align = "center" }, {
|
|
ui.glyph({ name = "charging-pile", size = 14 }),
|
|
ui.label({ text = tostring(threshold) .. "%", fontWeight = "bold" }),
|
|
}))
|
|
barWidget.setTooltip(
|
|
noctalia.tr("panel.title") .. " " .. tostring(threshold) .. "%"
|
|
)
|
|
else
|
|
barWidget.render(container({ gap = 4, align = "center" }, {
|
|
ui.glyph({ name = "charging-pile", size = 14, color = "on_surface/0.4" }),
|
|
}))
|
|
barWidget.setTooltip(noctalia.tr("settings.no-battery-device"))
|
|
end
|
|
end
|
|
|
|
noctalia.state.watch("current_threshold", render_widget)
|
|
noctalia.state.watch("is_available", render_widget)
|
|
|
|
function onClick()
|
|
noctalia.togglePanel("damian-ds7/battery-threshold:panel")
|
|
end
|
|
|
|
function update()
|
|
render_widget()
|
|
end
|
|
|
|
render_widget()
|