feat: move status-bar to seperate repository, initial commit
This commit is contained in:
19
widget/cpu-widget.tsx
Normal file
19
widget/cpu-widget.tsx
Normal file
@@ -0,0 +1,19 @@
|
||||
import { bind, GLib, Variable } from "astal";
|
||||
import { calc_cpu_usage, get_cpu_snapshot } from "./cpu";
|
||||
|
||||
let s1 = get_cpu_snapshot();
|
||||
let cpu_usage_percent = Variable(0);
|
||||
GLib.timeout_add(GLib.PRIORITY_DEFAULT, 1000, () => {
|
||||
const s2 = get_cpu_snapshot();
|
||||
cpu_usage_percent.set(calc_cpu_usage(s1, s2));
|
||||
s1 = s2;
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
export default function Cpu() {
|
||||
return <box className="status-box">
|
||||
<label label={bind(cpu_usage_percent).as((u) => `${u}% `)} />
|
||||
</box>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user