organise stuff

This commit is contained in:
tristan 2023-12-30 01:31:26 +00:00
parent 3b63b8b52b
commit 52dff69cca
8 changed files with 149 additions and 124 deletions

View file

@ -69,12 +69,7 @@ with lib; let
};
};
resolutionType = types.submodule ({
x,
y,
freq,
...
}: {
resolutionType = types.submodule {
options = {
x = mkOption {
description = "x";
@ -92,45 +87,57 @@ with lib; let
default = 0;
};
};
});
displayType =
types.submodule
({...}: {
options = {
name = mkOption {
description = "name of the display";
};
description = mkOption {
description = "description of display from hyprctl monitors";
default = "";
};
scaling = mkOption {
type = types.float;
default = 1.0;
};
rotation = mkOption {
type = types.int;
default = 0;
};
resolution = mkOption {
description = "res";
type = resolutionType;
default = {};
};
position.x = mkOption {
default = -1;
type = types.int;
};
position.y = mkOption {
default = -1;
type = types.int;
};
wallpaper = mkOption {
description = "path to wallpaper";
default = "";
};
displayType = types.submodule {
options = {
name = mkOption {
description = "name of the display";
};
description = mkOption {
description = "description of display from hyprctl monitors";
default = "";
};
scaling = mkOption {
type = types.float;
default = 1.0;
};
rotation = mkOption {
type = types.int;
default = 0;
};
resolution = mkOption {
description = "res";
type = resolutionType;
default = {};
};
position.x = mkOption {
default = -1;
type = types.int;
};
position.y = mkOption {
default = -1;
type = types.int;
};
wallpaper = mkOption {
description = "path to wallpaper";
default = "";
};
workspaces = mkOption {
default = {};
type = types.submodule {
options = {
start = mkOption {
type = types.int;
};
end = mkOption {
type = types.int;
};
};
};
};
});
};
};
resUnset = res: (res.x == 0 || res.y == 0 || res.freq == 0);
@ -138,26 +145,42 @@ with lib; let
if resUnset res
then "preferred"
else "${toString res.x}x${toString res.y}@${toString res.freq}";
waybarWorkspaceConf = monitors: (map (display: {
${display.name} = display.workspaces.start;
})
monitors);
renderWorkspacesForHyprland = displays: (map hyprWorkspaceSetting displays);
hyprWorkspaceSetting = display:
specificDisplay display
+ ", "
+ toString display.workspaces.start;
in {
options.displays = {
enable = mkEnableOption "manage displays";
displays = mkOption {
type = types.listOf displayType;
default = [];
type = types.attrsOf displayType;
default = {};
};
};
config = mkIf cfg.enable {
home-manager.users.${user}.imports = [
{
wayland.windowManager.hyprland.settings.monitor =
mkIf (cfg.displays != [])
(renderDisplaysForHyprland cfg.displays);
systemd.user.services.swaybg = swaybgJob (attrValues cfg.displays);
systemd.user.services.swaybg = swaybgJob cfg.displays;
wayland.windowManager.sway.config.output =
mkIf (cfg.displays != [])
(renderDisplaysForSway cfg.displays);
programs.waybar.settings.mainBar."hyprland/workspaces".persistent_workspaces = waybarWorkspaceConf (attrValues cfg.displays);
wayland.windowManager = mkIf (cfg.displays != {}) {
hyprland.settings = {
monitor = renderDisplaysForHyprland (attrValues cfg.displays);
workspace = renderWorkspacesForHyprland (attrValues cfg.displays);
};
sway.config.output =
renderDisplaysForSway (attrValues cfg.displays);
};
}
];
};