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

View file

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