Set ags temp to N/A if it isn't available

This commit is contained in:
Thomas Avé 2024-12-07 23:34:35 +01:00
parent 06a17580a9
commit 8b14e9adfb
1 changed files with 7 additions and 7 deletions

View File

@ -80,18 +80,18 @@ function Time({ format = "%H:%M:%S" }): JSX.Element {
} }
function Temp(): JSX.Element { function Temp(): JSX.Element {
let label = Variable<string>("N/A");
if (sensorsAvailable) { if (sensorsAvailable) {
const temp = Variable<string>("").poll(5000, 'sensors', out => { label = Variable<string>("").poll(5000, 'sensors', out => {
const match = out.split('\n').find(line => line.includes('Tctl') || line.includes('Package'))?.match(/[0-9.]*°C/); const match = out.split('\n').find(line => line.includes('Tctl') || line.includes('Package'))?.match(/[0-9.]*°C/);
return match ? match[0] : "N/A"; return match ? match[0] : "N/A";
}) })
return <label
className="item blue"
onDestroy={() => temp.drop()}
label={temp()}
/>
} }
return <box /> return <label
className="item blue"
onDestroy={() => label.drop()}
label={label()}
/>
} }
function Memory(): JSX.Element { function Memory(): JSX.Element {