integrated waybar configuration cleanly into existing hyprland config

This commit is contained in:
KoenDR06 2025-08-29 17:18:18 +02:00
parent 90966f1b3e
commit 5e920cd892
8 changed files with 356 additions and 343 deletions

View file

@ -3,10 +3,11 @@
config,
...
}: let
inherit (lib) mkOption types mkIf trivial strings;
inherit (lib) mkOption types mkIf trivial strings lists;
inherit (builtins) concatStringsSep elem genList elemAt;
inherit (trivial) boolToString;
inherit (strings) floatToString;
inherit (lists) remove;
cfg = config.horseman.wm.hyprland;
homeCfg = config.horseman;
@ -1175,6 +1176,10 @@ in {
type = types.nullOr types.path;
default = null;
};
bar = mkOption {
type = types.enum ["" "left" "right" "top" "bottom"];
default = "";
};
};
});
};
@ -1215,6 +1220,20 @@ in {
});
};
};
waybar = {
formats = {
horizontal = mkOption {
type = types.attrs;
};
vertical = mkOption {
type = types.attrs;
};
};
modules = mkOption {
type = types.attrs;
};
};
};
config = mkIf cfg.enable {
@ -1676,6 +1695,71 @@ in {
)
}
'';
programs.waybar = {
enable = true;
settings = let
outputMap = location: (
remove null (
map (disp:
if (disp.bar == location)
then disp.output
else null)
cfg.config.monitors.displays
)
);
in {
topBar =
{
layer = "top";
position = "top";
output = outputMap "top";
modules-left = ["group/power"];
modules-center = ["hyprland/workspaces"];
modules-right = ["network" "pulseaudio" "memory" "cpu" "clock"];
}
// cfg.config.waybar.modules // cfg.config.waybar.formats.horizontal;
bottomBar =
{
layer = "top";
position = "bottom";
output = outputMap "bottom";
modules-left = ["group/power"];
modules-center = ["hyprland/workspaces"];
modules-right = ["network" "pulseaudio" "memory" "cpu" "clock"];
}
// cfg.config.waybar.modules // cfg.config.waybar.formats.horizontal;
rightBar =
{
layer = "top";
position = "right";
output = outputMap "right";
modules-left = ["group/power"];
modules-center = ["hyprland/workspaces"];
modules-right = ["battery" "clock"];
}
// cfg.config.waybar.modules // cfg.config.waybar.formats.vertical;
leftBar =
{
layer = "top";
position = "left";
output = outputMap "left";
modules-left = ["group/power"];
modules-center = ["hyprland/workspaces"];
modules-right = ["battery" "clock"];
}
// cfg.config.waybar.modules // cfg.config.waybar.formats.vertical;
};
};
xdg.configFile."waybar/style.css".source = ./config/waybar/style.css;
};
};
}