mirror of
https://github.com/Theaninova/TheaninovOS.git
synced 2026-01-05 23:32:48 +00:00
feat: update ags
This commit is contained in:
57
home/desktops/hyprland/ags/js/bar/buttons/System.js
Normal file
57
home/desktops/hyprland/ags/js/bar/buttons/System.js
Normal file
@@ -0,0 +1,57 @@
|
||||
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");
|
||||
Reference in New Issue
Block a user