Set ags temp to N/A if it isn't available
This commit is contained in:
parent
06a17580a9
commit
8b14e9adfb
|
@ -80,19 +80,19 @@ 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
|
return <label
|
||||||
className="item blue"
|
className="item blue"
|
||||||
onDestroy={() => temp.drop()}
|
onDestroy={() => label.drop()}
|
||||||
label={temp()}
|
label={label()}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
return <box />
|
|
||||||
}
|
|
||||||
|
|
||||||
function Memory(): JSX.Element {
|
function Memory(): JSX.Element {
|
||||||
const memory = Variable<string>("").poll(2000, "free", out => {
|
const memory = Variable<string>("").poll(2000, "free", out => {
|
||||||
|
|
Loading…
Reference in New Issue