mirror of
https://github.com/Theaninova/TheaninovOS.git
synced 2026-01-04 06:42:48 +00:00
feat: update ags
This commit is contained in:
30
home/desktops/hyprland/ags/js/dashboard/Dashboard.js
Normal file
30
home/desktops/hyprland/ags/js/dashboard/Dashboard.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import Widget from "resource:///com/github/Aylur/ags/widget.js";
|
||||
import DateColumn from "./DateColumn.js";
|
||||
import NotificationColumn from "./NotificationColumn.js";
|
||||
import PopupWindow from "../misc/PopupWindow.js";
|
||||
import options from "../options.js";
|
||||
|
||||
export default () =>
|
||||
PopupWindow({
|
||||
name: "dashboard",
|
||||
connections: [
|
||||
[
|
||||
options.bar.position,
|
||||
(self) => {
|
||||
self.anchor = [options.bar.position.value];
|
||||
if (options.bar.position.value === "top")
|
||||
self.transition = "slide_down";
|
||||
|
||||
if (options.bar.position.value === "bottom")
|
||||
self.transition = "slide_up";
|
||||
},
|
||||
],
|
||||
],
|
||||
child: Widget.Box({
|
||||
children: [
|
||||
NotificationColumn(),
|
||||
Widget.Separator({ orientation: 1 }),
|
||||
DateColumn(),
|
||||
],
|
||||
}),
|
||||
});
|
||||
70
home/desktops/hyprland/ags/js/dashboard/DateColumn.js
Normal file
70
home/desktops/hyprland/ags/js/dashboard/DateColumn.js
Normal file
@@ -0,0 +1,70 @@
|
||||
import Widget from "resource:///com/github/Aylur/ags/widget.js";
|
||||
import icons from "../icons.js";
|
||||
import Clock from "../misc/Clock.js";
|
||||
import * as vars from "../variables.js";
|
||||
import options from "../options.js";
|
||||
|
||||
/**
|
||||
* @param {'cpu' | 'ram' | 'temp'} type
|
||||
* @param {string} title
|
||||
* @param {string} unit
|
||||
*/
|
||||
const SysProgress = (type, title, unit) =>
|
||||
Widget.Box({
|
||||
class_name: `circular-progress-box ${type}`,
|
||||
hexpand: true,
|
||||
binds: [
|
||||
[
|
||||
"tooltipText",
|
||||
vars[type],
|
||||
"value",
|
||||
(v) => `${title}: ${Math.floor(v * 100)}${unit}`,
|
||||
],
|
||||
],
|
||||
child: Widget.CircularProgress({
|
||||
hexpand: true,
|
||||
class_name: `circular-progress ${type}`,
|
||||
child: Widget.Icon(icons.system[type]),
|
||||
start_at: 0.75,
|
||||
binds: [
|
||||
["value", vars[type]],
|
||||
["rounded", options.radii, "value", (v) => v > 0],
|
||||
],
|
||||
}),
|
||||
});
|
||||
|
||||
export default () =>
|
||||
Widget.Box({
|
||||
vertical: true,
|
||||
class_name: "datemenu vertical",
|
||||
children: [
|
||||
Widget.Box({
|
||||
class_name: "clock-box",
|
||||
vertical: true,
|
||||
children: [
|
||||
Clock({ format: "%H:%M" }),
|
||||
Widget.Label({
|
||||
class_name: "uptime",
|
||||
binds: [["label", vars.uptime, "value", (t) => `uptime: ${t}`]],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
Widget.Box({
|
||||
class_name: "calendar",
|
||||
children: [
|
||||
Widget.Calendar({
|
||||
hexpand: true,
|
||||
hpack: "center",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
Widget.Box({
|
||||
class_name: "system-info horizontal",
|
||||
children: [
|
||||
SysProgress("cpu", "Cpu", "%"),
|
||||
SysProgress("ram", "Ram", "%"),
|
||||
SysProgress("temp", "Temperature", "°"),
|
||||
],
|
||||
}),
|
||||
],
|
||||
});
|
||||
@@ -0,0 +1,90 @@
|
||||
import Widget from "resource:///com/github/Aylur/ags/widget.js";
|
||||
import Notifications from "resource:///com/github/Aylur/ags/service/notifications.js";
|
||||
import icons from "../icons.js";
|
||||
import Notification from "../misc/Notification.js";
|
||||
import { timeout } from "resource:///com/github/Aylur/ags/utils.js";
|
||||
|
||||
const ClearButton = () =>
|
||||
Widget.Button({
|
||||
on_clicked: () => {
|
||||
const list = Array.from(Notifications.notifications);
|
||||
for (let i = 0; i < list.length; i++)
|
||||
timeout(50 * i, () => list[i]?.close());
|
||||
},
|
||||
binds: [["sensitive", Notifications, "notifications", (n) => n.length > 0]],
|
||||
child: Widget.Box({
|
||||
children: [
|
||||
Widget.Label("Clear "),
|
||||
Widget.Icon({
|
||||
binds: [
|
||||
[
|
||||
"icon",
|
||||
Notifications,
|
||||
"notifications",
|
||||
(n) => (n.length > 0 ? icons.trash.full : icons.trash.empty),
|
||||
],
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
});
|
||||
|
||||
const Header = () =>
|
||||
Widget.Box({
|
||||
class_name: "header",
|
||||
children: [
|
||||
Widget.Label({ label: "Notifications", hexpand: true, xalign: 0 }),
|
||||
ClearButton(),
|
||||
],
|
||||
});
|
||||
|
||||
const NotificationList = () =>
|
||||
Widget.Box({
|
||||
vertical: true,
|
||||
vexpand: true,
|
||||
connections: [
|
||||
[
|
||||
Notifications,
|
||||
(box) => {
|
||||
box.children = Notifications.notifications
|
||||
.reverse()
|
||||
.map(Notification);
|
||||
|
||||
box.visible = Notifications.notifications.length > 0;
|
||||
},
|
||||
],
|
||||
],
|
||||
});
|
||||
|
||||
const Placeholder = () =>
|
||||
Widget.Box({
|
||||
class_name: "placeholder",
|
||||
vertical: true,
|
||||
vpack: "center",
|
||||
hpack: "center",
|
||||
vexpand: true,
|
||||
hexpand: true,
|
||||
children: [
|
||||
Widget.Icon(icons.notifications.silent),
|
||||
Widget.Label("Your inbox is empty"),
|
||||
],
|
||||
binds: [["visible", Notifications, "notifications", (n) => n.length === 0]],
|
||||
});
|
||||
|
||||
export default () =>
|
||||
Widget.Box({
|
||||
class_name: "notifications",
|
||||
vertical: true,
|
||||
children: [
|
||||
Header(),
|
||||
Widget.Scrollable({
|
||||
vexpand: true,
|
||||
class_name: "notification-scrollable",
|
||||
child: Widget.Box({
|
||||
class_name: "notification-list",
|
||||
vertical: true,
|
||||
children: [NotificationList(), Placeholder()],
|
||||
}),
|
||||
}),
|
||||
],
|
||||
});
|
||||
Reference in New Issue
Block a user