Files
TheaninovOS/home/desktops/hyprland/ags/js/bar/buttons/System.js
2023-12-30 20:38:47 +01:00

58 lines
1.4 KiB
JavaScript

import Widget from "resource:///com/github/Aylur/ags/widget.js";
import PanelButton from "../PanelButton.js";
import * as variables from "../../variables.js";
import icons from "../../icons.js";
/** @param {'cpu' | 'ram'} type */
const System = (type) => {
const icon = Widget.Icon({
class_name: "icon",
icon: icons.system[type],
});
const progress = Widget.Box({
class_name: "progress",
child: Widget.CircularProgress({
binds: [["value", variables[type]]],
}),
});
const revealer = Widget.Revealer({
transition: "slide_right",
child: Widget.Label({
binds: [
[
"label",
variables[type],
"value",
(v) => {
return ` ${type}: ${Math.round(v * 100)}%`;
},
],
],
}),
});
return PanelButton({
class_name: `system ${type}`,
on_clicked: () => (revealer.reveal_child = !revealer.reveal_child),
content: Widget.EventBox({
on_hover: () => (revealer.reveal_child = true),
on_hover_lost: () => (revealer.reveal_child = false),
child: Widget.Box({
children: [
icon,
Widget.Box({
class_name: "revealer",
child: revealer,
}),
progress,
],
}),
}),
});
};
export const CPU = () => System("cpu");
export const RAM = () => System("ram");