feat(home): Assign workspaces to monitors
This commit is contained in:
parent
d8a55f9555
commit
bdfe9882c2
2 changed files with 105 additions and 10 deletions
|
@ -55,10 +55,11 @@ in {
|
||||||
};
|
};
|
||||||
wayland.hyprland = {
|
wayland.hyprland = {
|
||||||
enable = true;
|
enable = true;
|
||||||
monitors = [
|
monitors = {
|
||||||
"desc:Apple Computer Inc LED Cinema 2A91946Z0K0, 1920x1200, 0x0, 1"
|
"DP-1" = "desc:Apple Computer Inc LED Cinema 2A91946Z0K0, 1920x1200, 0x0, 1";
|
||||||
"desc:Lenovo Group Limited LT2252p Wide 6V8ACF74, 1680x1050, 1920x0, 1"
|
"HDMI-A-1" = "desc:Lenovo Group Limited LT2252p Wide 6V8ACF74, 1680x1050, 1920x0, 1";
|
||||||
];
|
};
|
||||||
|
mainMonitor = "DP-1";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,28 @@
|
||||||
config,
|
config,
|
||||||
inputs,
|
inputs,
|
||||||
system,
|
system,
|
||||||
|
pkgs,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib) mkEnableOption mkOption mkIf getExe;
|
inherit
|
||||||
|
(lib)
|
||||||
|
mkEnableOption
|
||||||
|
mkOption
|
||||||
|
mkIf
|
||||||
|
length
|
||||||
|
attrNames
|
||||||
|
range
|
||||||
|
zipListsWith
|
||||||
|
subtractLists
|
||||||
|
sublist
|
||||||
|
mapAttrs
|
||||||
|
replicate
|
||||||
|
last
|
||||||
|
getExe
|
||||||
|
concatLists
|
||||||
|
attrValues
|
||||||
|
listToAttrs
|
||||||
|
;
|
||||||
|
|
||||||
cfg = config.marleyos.wayland.hyprland;
|
cfg = config.marleyos.wayland.hyprland;
|
||||||
in {
|
in {
|
||||||
|
@ -14,12 +33,28 @@ in {
|
||||||
|
|
||||||
monitors = mkOption {
|
monitors = mkOption {
|
||||||
description = "Monitor configuration.";
|
description = "Monitor configuration.";
|
||||||
type = with lib.types; listOf str;
|
type = with lib.types; attrsOf str;
|
||||||
default = [];
|
};
|
||||||
|
|
||||||
|
mainMonitor = mkOption {
|
||||||
|
description = "Which monitor to treat as the main for workspace assignment";
|
||||||
|
type = with lib.types; str;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = 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;
|
marleyos.programs.wofi.enable = true;
|
||||||
|
|
||||||
wayland.windowManager.hyprland = {
|
wayland.windowManager.hyprland = {
|
||||||
|
@ -28,12 +63,71 @@ in {
|
||||||
systemd.enable = true;
|
systemd.enable = true;
|
||||||
xwayland.enable = true;
|
xwayland.enable = true;
|
||||||
|
|
||||||
settings = {
|
settings = let
|
||||||
monitor = cfg.monitors;
|
numMonitors = length (attrNames (cfg.monitors or {}));
|
||||||
|
workspaces = range 1 10;
|
||||||
|
wsPerMonitor = 10 / numMonitors;
|
||||||
|
|
||||||
|
mainMonWs = range 1 wsPerMonitor;
|
||||||
|
secondaryWs = subtractLists mainMonWs workspaces;
|
||||||
|
|
||||||
|
monitors = mapAttrs (mon: _:
|
||||||
|
if (mon == (cfg.mainMonitor or ""))
|
||||||
|
then ""
|
||||||
|
else replicate wsPerMonitor "${mon}")
|
||||||
|
(cfg.monitors or {});
|
||||||
|
|
||||||
|
secondaryMons = removeAttrs monitors [(cfg.mainMonitor or "")];
|
||||||
|
monList = concatLists (attrValues secondaryMons);
|
||||||
|
|
||||||
|
firstWsToMons =
|
||||||
|
zipListsWith (mon: ws: {
|
||||||
|
name = toString ws;
|
||||||
|
value = mon;
|
||||||
|
})
|
||||||
|
monList
|
||||||
|
secondaryWs;
|
||||||
|
|
||||||
|
leftover =
|
||||||
|
sublist (length monList) (10 - (wsPerMonitor * numMonitors)) secondaryWs;
|
||||||
|
|
||||||
|
wsToMons =
|
||||||
|
firstWsToMons
|
||||||
|
++ (map (ws: {
|
||||||
|
name = toString ws;
|
||||||
|
value = last monList;
|
||||||
|
})
|
||||||
|
leftover)
|
||||||
|
++ (map (ws: {
|
||||||
|
name = toString ws;
|
||||||
|
value = cfg.mainMonitor or "";
|
||||||
|
})
|
||||||
|
mainMonWs);
|
||||||
|
|
||||||
|
wsMons = listToAttrs wsToMons;
|
||||||
|
in {
|
||||||
|
monitor = attrValues cfg.monitors;
|
||||||
|
|
||||||
# TODO: Use overlay once it's made.
|
# TODO: Use overlay once it's made.
|
||||||
"$terminal" = getExe inputs.wezterm.packages."${system}".default;
|
"$terminal" = getExe inputs.wezterm.packages."${system}".default;
|
||||||
"$launcher" = "wofi --show drun";
|
"$launcher" = "${getExe pkgs.wofi} --show drun";
|
||||||
|
|
||||||
|
exec-once = let
|
||||||
|
browserWs =
|
||||||
|
if (cfg ? monitors)
|
||||||
|
then wsPerMonitor + 1
|
||||||
|
else 2;
|
||||||
|
in [
|
||||||
|
"[workspace 1 silent] $terminal"
|
||||||
|
# TODO: Change once waterfox is set up
|
||||||
|
"[workspace ${toString browserWs} silent] firefox"
|
||||||
|
];
|
||||||
|
|
||||||
|
workspace =
|
||||||
|
mkIf (cfg ? monitors)
|
||||||
|
(map
|
||||||
|
(ws: "${toString ws}, monitor:${wsMons."${toString ws}"}")
|
||||||
|
workspaces);
|
||||||
|
|
||||||
"$mod" = "SUPER";
|
"$mod" = "SUPER";
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue