Update ags for hyprland

This commit is contained in:
2025-05-18 21:03:40 +02:00
parent ed8d1a7ca7
commit 4e73628d6c
8 changed files with 51 additions and 120 deletions
+4 -2
View File
@@ -44,6 +44,7 @@ misc {
binds {
allow_workspace_cycles = true
workspace_back_and_forth = true
movefocus_cycles_fullscreen = true
}
@@ -129,8 +130,9 @@ bind = Super, 9, focusworkspaceoncurrentmonitor, 9
bind = Super+Shift, 9, movetoworkspacesilent, 9
bind = Super, r, exec, uwsm app -- $BROWSER
bind = Super, e, exec, uwsm app -- $TERMINAL
# TODO: use $BROWSER/$TERMINAL
bind = Super, r, exec, uwsm app -- zen
bind = Super, e, exec, uwsm app -- kitty
bind = Super, p, exec, rofi -show drun -show-icons -run-command "uwsm app -- {cmd}"
bind = Super, x, exec, screenshot
bind = Super+Control, x, exec, screenshot-freeze
Generated
-21
View File
@@ -1,25 +1,5 @@
{
"nodes": {
"astal": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1747093850,
"narHash": "sha256-SaHAtzUyfm4urAcUEZlBFn7dWhoDqA6kaeFZ11CCTf8=",
"owner": "aylur",
"repo": "astal",
"rev": "4820a3e37cc8eb81db6ed991528fb23472a8e4de",
"type": "github"
},
"original": {
"owner": "aylur",
"repo": "astal",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
@@ -381,7 +361,6 @@
},
"root": {
"inputs": {
"astal": "astal",
"flood": "flood",
"home-manager": "home-manager",
"impermanence": "impermanence",
-4
View File
@@ -23,10 +23,6 @@
url = "github:zoriya/flood";
flake = false;
};
astal = {
url = "github:aylur/astal";
inputs.nixpkgs.follows = "nixpkgs";
};
river-src = {
url = "github:zoriya/river/0.3.x";
flake = false;
+1 -6
View File
@@ -1,8 +1,4 @@
{
pkgs,
astal,
...
}: let
{pkgs, ...}: let
covercolors = pkgs.stdenv.mkDerivation {
name = "covercolors";
dontUnpack = true;
@@ -21,7 +17,6 @@
prev.buildInputs
++ [
pkgs.libdbusmenu-gtk3
astal.packages.${pkgs.system}.river
];
});
in {
-1
View File
@@ -25,7 +25,6 @@ export const Bar = (monitor) =>
monitor,
labels: ["一", "二", "三", "四", "五", "六", "七", "八", "九"],
}),
wm.Layout({ monitor }),
wm.ClientLabel({ monitor }),
],
}),
+45 -79
View File
@@ -1,99 +1,65 @@
import Gdk from "gi://Gdk?version=3.0";
import AstalRiver from "gi://AstalRiver";
const river = AstalRiver.River.get_default();
const hyprland = await Service.import("hyprland");
const display = Gdk.Display.get_default();
/** @param {number} monitor */
const getOutput = (monitor) => {
const monitorName = display
.get_default_screen()
.get_monitor_plug_name(monitor);
return river.get_output(monitorName);
const getMonitorName = (monitor) => {
return display.get_default_screen().get_monitor_plug_name(monitor);
};
/** @param {{monitor: number, labels: string[]} & import("types/widgets/box").BoxProps} props */
export const Tags = ({ monitor, labels, ...props }) =>
Widget.Box(props).hook(
river,
(self) => {
const output = getOutput(monitor);
if (!output) return;
const focused = output.focused_tags;
const occupied = output.occupied_tags;
const urgent = output.urgent_tags;
self.children = Array.from({ length: 9 }, (_, i) => i).map((i) =>
TagItem({
output,
occupied: !!(occupied & (1 << i)),
selected: !!(focused & (1 << i)),
urgent: !!(urgent & (1 << i)),
i,
label: labels[i],
}),
);
self.children.forEach((button, i) => {
// We need to set this here because assigning children to self calls show_all() and ignore visibility
// @ts-ignore
button.visible = button.attribute;
});
},
"changed",
);
/** @param {{
* occupied: boolean,
* selected: boolean,
* urgent: boolean,
* i: number,
* output: any,
* label: string
* }} props */
const TagItem = ({ occupied, selected, urgent, i, output, label }) =>
Widget.EventBox({
classNames: [selected ? "accent" : "", urgent ? "secondary" : ""],
attribute: occupied || selected,
onPrimaryClickRelease: () => {
river.run_command_async(["set-focused-tags", `${1 << i}`], null);
},
onSecondaryClickRelease: () => {
const tags = output.get_focused_tags() ^ (1 << i);
river.run_command_async(["set-focused-tags", `${tags}`], null);
},
onMiddleClickRelease: () => {
river.run_command_async(["set-view-tags", `${1 << i}`], null);
},
child: Widget.Label({ label, className: "tags" }),
});
/** @param {{monitor: number } & import("types/widgets/label").LabelProps} props */
export const Layout = ({ monitor, ...props }) =>
Widget.Label({
className: "module",
export const Tags = ({ monitor, labels, ...props }) => {
const monName = getMonitorName(monitor);
// @ts-ignore
return Widget.Box({
...props,
}).hook(
river,
(self) => {
const output = getOutput(monitor);
if (!output) return;
self.label = output.layout_name;
},
"changed",
);
children: Array.from({ length: 9 }, (_, i) => i).map((i) =>
Widget.EventBox({
child: Widget.Label({ label: labels[i], className: "tags" }),
attribute: i + 1,
onPrimaryClickRelease: () => {
hyprland.message(`dispatch workspace ${i + 1}`);
},
}),
),
setup: (self) =>
self.hook(hyprland, () =>
self.children.forEach((btn) => {
const mon = hyprland.monitors.find((x) => x.name === monName);
const ws = hyprland.workspaces.find((x) => x.id === btn.attribute);
const occupied = (ws?.windows ?? 0) > 0;
const selected = mon?.activeWorkspace?.id === btn.attribute;
const urgent = false;
btn.visible = occupied || selected;
btn.class_names = [
selected ? "accent" : "",
urgent ? "secondary" : "",
];
}),
),
});
};
/** @param {{monitor: number, fallback?: string} & import("types/widgets/label").LabelProps} props */
export const ClientLabel = ({ monitor, fallback = "", ...props }) =>
Widget.Label({
export const ClientLabel = ({ monitor, fallback = "", ...props }) => {
const monName = getMonitorName(monitor);
return Widget.Label({
truncate: "end",
maxWidthChars: 25,
className: "module",
...props,
}).hook(
river,
hyprland,
(self) => {
const output = getOutput(monitor);
if (!output) return;
self.label = output.focused_view || fallback;
const mon = hyprland.monitors.find((x) => x.name === monName);
const ws = hyprland.workspaces.find(
(x) => x.id === mon?.activeWorkspace?.id,
);
self.label = ws?.lastwindowtitle || fallback;
},
"changed",
);
};
-6
View File
@@ -1,6 +0,0 @@
{pkgs ? import <nixpkgs> {}}:
pkgs.mkShell {
packages = with pkgs; [
biome
];
}
+1 -1
View File
@@ -1 +1 @@
/nix/store/bvbfvg7s1n35wv0afs7krkvppj6dx538-ags-1.8.2/share/com.github.Aylur.ags/types
/nix/store/g5s50dy9za9inrw5zps05s7kh4ypnbpa-ags-1.8.2/share/com.github.Aylur.ags/types