feat: improve AGS JavaScript definition files

This commit is contained in:
Zhongheng Liu 2024-08-22 17:07:24 +08:00
commit 9ac744a8ce
No known key found for this signature in database
2 changed files with 19 additions and 17 deletions

View file

@ -12,28 +12,30 @@ const date = Variable("", {
// so to make a reuseable widget, make it a function
// then you can simply instantiate one by calling it
const focusedTitle = Widget.Label({
label: hyprland.active.client.bind('title'),
visible: hyprland.active.client.bind('address')
.as(addr => addr !== "0x"),
label: hyprland.active.client.bind('title'),
visible: hyprland.active.client.bind('address')
.as(addr => addr !== "0x"),
})
const dispatch = ws => hyprland.messageAsync(`dispatch workspace ${ws}`);
const Workspaces = () => Widget.EventBox({
onScrollUp: () => dispatch('+1'),
onScrollDown: () => dispatch('-1'),
child: Widget.Box({
children: Array.from({ length: 10 }, (_, i) => i + 1).map(i => Widget.Button({
attribute: i,
label: `${i}`,
onClicked: () => dispatch(i),
})),
onScrollUp: () => dispatch('+1'),
onScrollDown: () => dispatch('-1'),
child: Widget.Box({
children: Array.from({ length: 10 }, (_, i) => i + 1).map(i => Widget.Button({
attribute: i,
label: `${i}`,
onClicked: () => dispatch(i),
// remove this setup hook if you want fixed number of buttons
setup: self => self.hook(hyprland, () => self.children.forEach(btn => {
btn.visible = hyprland.workspaces.some(ws => ws.id === btn.attribute);
})),
}),
class_name: i === hyprland.active.workspace.id ? "focused" : ""
})),
// remove this setup hook if you want fixed number of buttons
setup: self => self.hook(hyprland, () => self.children.forEach(btn => {
btn.visible = hyprland.workspaces.some(ws => ws.id === btn.attribute);
})),
}),
})
function ClientTitle() {
return Widget.Label({

View file

@ -12,7 +12,7 @@
home.packages = with pkgs; [ags];
myAutostartCommands = [
#"${pkgs.ags}/bin/ags --init"
#"${pkgs.ags}/bin/ags"
"${pkgs.ags}/bin/ags"
];
};
}