Generalize monitors so they work across WMs

This commit is contained in:
Natsu Kagami 2025-01-16 04:23:20 +01:00
parent 79c213bd64
commit 704f1f1c79
Signed by: nki
GPG key ID: 55A032EB38B49ADB
4 changed files with 25 additions and 27 deletions

View file

@ -47,28 +47,13 @@
wayland.windowManager.sway.config.input."type:keyboard".xkb_layout = "jp"; wayland.windowManager.sway.config.input."type:keyboard".xkb_layout = "jp";
wayland.windowManager.sway.config.input."type:pointer".accel_profile = "flat"; wayland.windowManager.sway.config.input."type:pointer".accel_profile = "flat";
# 144hz adaptive refresh ON! # 144hz adaptive refresh ON!
wayland.windowManager.sway.config.output =
let
scale = 1.5;
top_x = builtins.ceil (3840 / scale);
top_y = 0;
in
with config.common.monitors; {
${home_4k.name} = {
scale = toString scale;
position = "0 0";
};
${home_1440.name} = {
position = "${toString top_x} ${toString top_y}";
};
};
nki.programs.kitty.enable = true; nki.programs.kitty.enable = true;
nki.programs.kitty.fontSize = 14; nki.programs.kitty.fontSize = 14;
programs.my-waybar.makeBars = with config.common.monitors; barWith: [ programs.my-waybar.makeBars = with config.common.monitors; barWith: [
# For primary # For primary
(barWith { extraSettings = { output = [ home_4k.name ]; }; }) (barWith { extraSettings = { output = [ home_4k.meta.connection ]; }; })
# For secondary, hide mpd # For secondary, hide mpd
(barWith { showMedia = false; showConnectivity = false; extraSettings = { output = [ home_1440.name ]; }; }) (barWith { showMedia = false; showConnectivity = false; extraSettings = { output = [ home_1440.meta.connection ]; }; })
]; ];
# Yellow light! # Yellow light!

View file

@ -11,7 +11,7 @@ let
style = ./swaync.css; style = ./swaync.css;
}; };
systemd.user.services.swaync.Install.WantedBy = lib.mkForce [ "sway-session.target" ]; systemd.user.services.swaync.Install.WantedBy = lib.mkForce [ "sway-session.target" ];
systemd.user.services.swaync.Unit.PartOf = lib.mkForce [ "sway-session.target" ]; systemd.user.services.swaync.Unit.PartOf = lib.mkForce [ "graphical-session.target" ];
programs.my-waybar = { programs.my-waybar = {
extraSettings = [{ extraSettings = [{

View file

@ -5,32 +5,41 @@ let
# Internal # Internal
"framework" = { "framework" = {
name = "BOE 0x0BCA Unknown"; name = "BOE 0x0BCA Unknown";
mode = "2256x1504@60Hz"; meta.mode = { width = 2256; height = 1504; refresh = 60.0; };
scale = 1.25; scale = 1.25;
}; };
# External # External
## Work @ EPFL ## Work @ EPFL
"work" = { "work" = {
name = "LG Electronics LG ULTRAFINE 301MAXSGHD10"; name = "LG Electronics LG ULTRAFINE 301MAXSGHD10";
mode = "3840x2160@60Hz"; meta.mode = { width = 3840; height = 2160; refresh = 60.0; };
scale = 1.25; scale = 1.25;
}; };
"home_4k" = { "home_4k" = {
name = "AOC U28G2G6B PPYP2JA000013"; name = "AOC U28G2G6B PPYP2JA000013";
mode = "3840x2160@60Hz";
scale = 1.5; scale = 1.5;
adaptive_sync = "on"; adaptive_sync = "on";
# render_bit_depth = "10"; meta = {
connection = "DP-2";
mode = { width = 3840; height = 2160; refresh = 60.0; };
fixedPosition = { x = 0; y = 0; };
niriName = "PNP(AOC) U28G2G6B PPYP2JA000013";
};
}; };
"home_1440" = { "home_1440" = {
name = "AOC Q27G2G3R3B VXJP6HA000442"; name = "AOC Q27G2G3R3B VXJP6HA000442";
mode = "2560x1440@165Hz";
adaptive_sync = "on"; adaptive_sync = "on";
meta = {
connection = "DP-3";
mode = { width = 2560; height = 1440; refresh = 165.0; };
fixedPosition = { x = 2560; y = 0; };
niriName = "PNP(AOC) Q27G2G3R3B VXJP6HA000442";
};
}; };
"viewsonic_1080" = { "viewsonic_1080" = {
name = "ViewSonic Corporation XG2402 SERIES V4K182501054"; name = "ViewSonic Corporation XG2402 SERIES V4K182501054";
mode = "1920x1080@144Hz"; meta.mode = { width = 1920; height = 1080; refresh = 144.0; };
adaptive_sync = "on"; adaptive_sync = "on";
}; };
@ -38,9 +47,13 @@ let
eachMonitor = _name: monitor: { eachMonitor = _name: monitor: {
name = monitor.name; name = monitor.name;
value = builtins.removeAttrs monitor [ "scale" "name" ] // (if monitor ? scale then { value = builtins.removeAttrs monitor [ "scale" "name" "meta" ] // (lib.optionalAttrs (monitor ? scale) {
scale = toString monitor.scale; scale = toString monitor.scale;
} else { }); }) // {
mode = with monitor.meta.mode; "${toString width}x${toString height}@${toString refresh}Hz";
} // (lib.optionalAttrs (monitor.meta ? fixedPosition) {
position = with monitor.meta.fixedPosition; "${toString x} ${toString y}";
});
}; };
in in
{ {

View file

@ -240,7 +240,7 @@ in
lib.mkIf cfg.enable { lib.mkIf cfg.enable {
enable = true; enable = true;
systemd.enable = true; systemd.enable = true;
systemd.target = "sway-session.target"; systemd.target = "graphical-session.target";
settings = cfg.makeBars barWith; settings = cfg.makeBars barWith;
style = '' style = ''
* { * {