Feat: Peripheral status and integration #140
+1
-1
@@ -21,7 +21,7 @@ Singleton {
|
|||||||
readonly property bool ready: UPower.displayDevice.ready
|
readonly property bool ready: UPower.displayDevice.ready
|
||||||
readonly property real timeToEmpty: UPower.displayDevice.timeToEmpty
|
readonly property real timeToEmpty: UPower.displayDevice.timeToEmpty
|
||||||
readonly property real timeToFull: UPower.displayDevice.timeToFull
|
readonly property real timeToFull: UPower.displayDevice.timeToFull
|
||||||
readonly property list<UPowerDevice> upowerDevices: UPower.devices.values
|
readonly property list<UPowerDevice> upowerDevices: UPower.devices.values.filter(d => d.state !== UPowerDeviceState.Unknown)
|
||||||
|
|
||||||
function getColors(percentage: real, state: string): var {
|
function getColors(percentage: real, state: string): var {
|
||||||
if (state === "charging" || state === "full" || state === "recharging")
|
if (state === "charging" || state === "full" || state === "recharging")
|
||||||
|
|||||||
@@ -229,11 +229,15 @@ def daemon(
|
|||||||
|
|
||||||
typer.echo(f"Polling every {interval}s, writing to {out}")
|
typer.echo(f"Polling every {interval}s, writing to {out}")
|
||||||
|
|
||||||
|
last_payload = None
|
||||||
try:
|
try:
|
||||||
while running:
|
while running:
|
||||||
try:
|
try:
|
||||||
results = poll_once()
|
results = poll_once()
|
||||||
|
payload = [asdict(r) for r in results]
|
||||||
|
if payload != last_payload:
|
||||||
_write_json_atomic(out, results)
|
_write_json_atomic(out, results)
|
||||||
|
last_payload = payload
|
||||||
except RuntimeError as e:
|
except RuntimeError as e:
|
||||||
typer.echo(f"error: {e}", err=True)
|
typer.echo(f"error: {e}", err=True)
|
||||||
raise typer.Exit(code=1) from None
|
raise typer.Exit(code=1) from None
|
||||||
|
|||||||
Reference in New Issue
Block a user