181 lines
4.9 KiB
Nix
181 lines
4.9 KiB
Nix
{
|
|
lib,
|
|
config,
|
|
inputs,
|
|
pkgs,
|
|
...
|
|
}: let
|
|
inherit (lib.marleyos) enabled;
|
|
|
|
cfg = config.marleyos.wayland.hyprland;
|
|
inherit (config.marleyos.theme) colors;
|
|
in {
|
|
options.marleyos.wayland.hyprland = {
|
|
enable = lib.mkEnableOption "hyprland";
|
|
|
|
monitors = lib.mkOption {
|
|
description = "Monitor configuration.";
|
|
type = with lib.types; attrsOf str;
|
|
};
|
|
|
|
mainMonitor = lib.mkOption {
|
|
description = "Which monitor to treat as the main for workspace assignment";
|
|
type = with lib.types; str;
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
assertions = [
|
|
{
|
|
assertion =
|
|
if cfg ? monitors
|
|
then cfg ? mainMonitor
|
|
else true;
|
|
message = ''
|
|
You have defined monitors but not selected the main monitor. Please
|
|
define marleyos.wayland.hyprland.mainMonitor.
|
|
'';
|
|
}
|
|
];
|
|
|
|
marleyos.programs.wofi.enable = true;
|
|
|
|
home.pointerCursor.hyprcursor.enable = true;
|
|
home.packages = [
|
|
inputs.rose-pine-hyprcursor.packages.${pkgs.system}.default
|
|
];
|
|
|
|
wayland.windowManager.hyprland = {
|
|
enable = true;
|
|
|
|
systemd.enable = true;
|
|
xwayland.enable = true;
|
|
|
|
rose-pine = lib.mkIf colors.isRosePine enabled;
|
|
|
|
settings = let
|
|
numMonitors = lib.length (lib.attrNames (cfg.monitors or {}));
|
|
workspaces = lib.range 1 10;
|
|
wsPerMonitor = 10 / numMonitors;
|
|
|
|
mainMonWs = lib.range 1 wsPerMonitor;
|
|
secondaryWs = lib.subtractLists mainMonWs workspaces;
|
|
|
|
monitors = lib.mapAttrs (mon: _:
|
|
if (mon == (cfg.mainMonitor or ""))
|
|
then ""
|
|
else lib.replicate wsPerMonitor "${mon}")
|
|
(cfg.monitors or {});
|
|
|
|
secondaryMons = removeAttrs monitors [(cfg.mainMonitor or "")];
|
|
monList = lib.concatLists (lib.attrValues secondaryMons);
|
|
|
|
firstWsToMons =
|
|
lib.zipListsWith (mon: ws: {
|
|
name = toString ws;
|
|
value = mon;
|
|
})
|
|
monList
|
|
secondaryWs;
|
|
|
|
leftover =
|
|
lib.sublist (lib.length monList) (10 - (wsPerMonitor * numMonitors)) secondaryWs;
|
|
|
|
wsToMons =
|
|
firstWsToMons
|
|
++ (map (ws: {
|
|
name = toString ws;
|
|
value = lib.last monList;
|
|
})
|
|
leftover)
|
|
++ (map (ws: {
|
|
name = toString ws;
|
|
value = cfg.mainMonitor or "";
|
|
})
|
|
mainMonWs);
|
|
|
|
wsMons = lib.listToAttrs wsToMons;
|
|
in {
|
|
monitor = lib.attrValues cfg.monitors;
|
|
|
|
# TODO: Set this in a default apps module.
|
|
"$terminal" = lib.getExe pkgs.wezterm;
|
|
"$launcher" = "${lib.getExe pkgs.wofi} --show drun";
|
|
# TODO: Set this in a default apps module.
|
|
"$browser" = "${lib.getExe pkgs.floorp}";
|
|
|
|
exec-once = let
|
|
browserWs =
|
|
if (cfg ? monitors)
|
|
then wsPerMonitor + 1
|
|
else 2;
|
|
in [
|
|
"[workspace 1 silent] $terminal"
|
|
"[workspace ${toString browserWs} silent] $browser"
|
|
];
|
|
|
|
# Fix WM thinking the cursor is bigger than it is, causing the pointer
|
|
# to be offset.
|
|
env =
|
|
[
|
|
"XCURSOR_SIZE,24"
|
|
"HYPRCURSOR_SIZE,24"
|
|
]
|
|
++ (lib.optional colors.isRosePine "HYPRCURSOR_THEME,rose-pine-hyprcursor");
|
|
|
|
workspace =
|
|
lib.mkIf (cfg ? monitors)
|
|
(map
|
|
(ws: "${toString ws}, monitor:${wsMons."${toString ws}"}")
|
|
workspaces);
|
|
|
|
"$mod" = "SUPER";
|
|
|
|
bind = [
|
|
"$mod, Q, killactive,"
|
|
"$mod SHIFT, E, exit,"
|
|
|
|
"$mod SHIFT, SPACE, togglefloating"
|
|
|
|
"$mod, RETURN, exec, $terminal"
|
|
"$mod, R, exec, $launcher"
|
|
|
|
"$mod, h, movefocus, l"
|
|
"$mod, j, movefocus, d"
|
|
"$mod, k, movefocus, u"
|
|
"$mod, l, movefocus, r"
|
|
|
|
"$mod, 1, workspace, 1"
|
|
"$mod, 2, workspace, 2"
|
|
"$mod, 3, workspace, 3"
|
|
"$mod, 4, workspace, 4"
|
|
"$mod, 5, workspace, 5"
|
|
"$mod, 6, workspace, 6"
|
|
"$mod, 7, workspace, 7"
|
|
"$mod, 8, workspace, 8"
|
|
"$mod, 9, workspace, 9"
|
|
"$mod, 0, workspace, 10"
|
|
|
|
"$mod SHIFT, 1, movetoworkspace, 1"
|
|
"$mod SHIFT, 2, movetoworkspace, 2"
|
|
"$mod SHIFT, 3, movetoworkspace, 3"
|
|
"$mod SHIFT, 4, movetoworkspace, 4"
|
|
"$mod SHIFT, 5, movetoworkspace, 5"
|
|
"$mod SHIFT, 6, movetoworkspace, 6"
|
|
"$mod SHIFT, 7, movetoworkspace, 7"
|
|
"$mod SHIFT, 8, movetoworkspace, 8"
|
|
"$mod SHIFT, 9, movetoworkspace, 9"
|
|
"$mod SHIFT, 0, movetoworkspace, 10"
|
|
];
|
|
|
|
# bindm = [
|
|
# "$mod, mouse_down, workspace, e+1"
|
|
# "$mod, mouse_up, workspace, e-1"
|
|
#
|
|
# "$mod, mouse:272, movewindow"
|
|
# "$mod, mouse:273, resizewindow"
|
|
# ];
|
|
};
|
|
};
|
|
};
|
|
}
|