mirror of
https://github.com/Theaninova/TheaninovOS.git
synced 2026-01-23 01:52:46 +00:00
feat: update ags
This commit is contained in:
34
home/desktops/hyprland/ags/js/bar/buttons/Taskbar.js
Normal file
34
home/desktops/hyprland/ags/js/bar/buttons/Taskbar.js
Normal file
@@ -0,0 +1,34 @@
|
||||
import Hyprland from "resource:///com/github/Aylur/ags/service/hyprland.js";
|
||||
import Applications from "resource:///com/github/Aylur/ags/service/applications.js";
|
||||
import Widget from "resource:///com/github/Aylur/ags/widget.js";
|
||||
import PanelButton from "../PanelButton.js";
|
||||
import { launchApp } from "../../utils.js";
|
||||
import icons from "../../icons.js";
|
||||
|
||||
const focus = ({ address }) =>
|
||||
Hyprland.sendMessage(`dispatch focuswindow address:${address}`);
|
||||
|
||||
/** @param {import('types/widgets/box').default} box */
|
||||
const setChildren = (box) =>
|
||||
(box.children = Hyprland.clients.map((client) => {
|
||||
if (Hyprland.active.workspace.id !== client.workspace.id) return;
|
||||
|
||||
for (const app of Applications.list) {
|
||||
if (client.class && app.match(client.class)) {
|
||||
return PanelButton({
|
||||
content: Widget.Icon(app.icon_name || icons.fallback.executable),
|
||||
tooltip_text: app.name,
|
||||
on_primary_click: () => focus(client),
|
||||
on_middle_click: () => launchApp(app),
|
||||
});
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
export default () =>
|
||||
Widget.Box({
|
||||
connections: [
|
||||
[Hyprland, setChildren, "notify::clients"],
|
||||
[Hyprland, setChildren, "notify::active"],
|
||||
],
|
||||
});
|
||||
Reference in New Issue
Block a user