Files
nixconfig/modules/home/wayland/apps/kanshi/default.nix
T
2026-09-10 19:54:50 +02:00

159 lines
6.8 KiB
Nix

{ config, lib, pkgs, ... }:
let
# Re-place the bar on the profile's main output. eww-bar waits for the
# daemon (kanshi and eww.service start together at login), and resolves the
# monitor by description on every hotplug, so the bar follows the profile
# instead of a GDK monitor index that changes as outputs come and go.
placeBar = screen: "${pkgs.custom.eww-bar}/bin/eww-bar place '${screen}'";
baseOutput = {
position = "0,0";
scale = 1.0;
adaptiveSync = true;
status = "enable";
transform = "normal";
};
aocT = "AOC 24E1W1 GNSKCHA086899";
aocB = "AOC 24E1W1 GNSKBHA080346";
lgM = "LG Electronics LG ULTRAGEAR+ 511NTDVGC194";
valinorM = "Lenovo Group Limited *";
in {
config = lib.mkIf (config.usercfg.wm == "Wayland") {
services.kanshi = {
enable = true;
systemdTarget = "graphical-session.target";
settings = [
{output = baseOutput//{
criteria = "LG Electronics LG ULTRAGEAR+ 511NTDVGC194";
# mode = "2560x1440@480.168";
mode = "2560x1440@240.083";
# mode = "1920x1080x240.084";
};}
{output = baseOutput//{
criteria = "AOC 24E1W1 GNSKCHA086899";
mode = "1920x1080@60.000";
transform = "180";
};}
{output = baseOutput//{
criteria = "AOC 24E1W1 GNSKBHA080346";
mode = "1920x1080@60.000";
};}
{output = baseOutput//{
criteria = "Lenovo Group Limited *";
mode = "1920x1080@60.020";
};}
{output = baseOutput//{
criteria = "AOC 16G3 1DDP7HA000348";
mode = "1920x1080@144.000";
};}
{profile = {
name = "tower_00";
outputs = [
{
criteria = aocT;
position = "0,0";
}
{
criteria = aocB;
position = "0,1080";
}
{
criteria = lgM;
position = "1920,720";
}
];
exec = [
(placeBar "desc:${aocB}")
"${pkgs.writeShellScript "kanshi-hyprland-init" ''
#!/usr/bin/env bash
${pkgs.hyprland}/bin/hyprctl eval '
hl.workspace_rule({ workspace = "1", monitor = "desc:${aocB}", default = true })
hl.workspace_rule({ workspace = "2", monitor = "desc:${aocT}", default = true })
hl.workspace_rule({ workspace = "3", monitor = "desc:${aocB}", default = true })
hl.workspace_rule({ workspace = "4", monitor = "desc:${aocB}", default = true })
hl.workspace_rule({ workspace = "5", monitor = "desc:${aocB}", default = true })
hl.workspace_rule({ workspace = "6", monitor = "desc:${aocB}", default = true })
hl.workspace_rule({ workspace = "7", monitor = "desc:${aocB}", default = true })
hl.workspace_rule({ workspace = "8", monitor = "desc:${aocT}", default = true })
hl.workspace_rule({ workspace = "9", monitor = "desc:${aocB}", default = true })
hl.workspace_rule({ workspace = "name:X", monitor = "desc:${lgM}", default = true })
'
${pkgs.hyprland}/bin/hyprctl eval 'hl.dispatch(hl.dsp.focus({ monitor = "desc:${aocT}" })); hl.dispatch(hl.dsp.focus({ workspace = "2" }));'
${pkgs.hyprland}/bin/hyprctl eval 'hl.dispatch(hl.dsp.focus({ monitor = "desc:${lgM}" })); hl.dispatch(hl.dsp.focus({ workspace = "name:X" }));'
#${pkgs.hyprland}/bin/hyprctl eval 'hl.monitor({ output = "desc:${lgM}", cm = "hdr" });'
${pkgs.hyprland}/bin/hyprctl eval 'hl.dispatch(hl.dsp.focus({ monitor = "desc:${aocB}" }));'
''}"
"${pkgs.awww}/bin/awww restore"
];
};}
{profile = {
name = "tower_01";
outputs = [
{
criteria = "AOC 24E1W1 GNSKCHA086899";
transform = "180";
position = "0,0";
}
{
criteria = "AOC 24E1W1 GNSKBHA080346";
position = "0,1080";
}
];
exec = [
"${pkgs.writeShellScript "kanshi-hyprland-init" ''
#!/usr/bin/env bash
${pkgs.hyprland}/bin/hyprctl eval '
hl.workspace_rule({ workspace = "1", monitor = "DP-1", default = true })
hl.workspace_rule({ workspace = "2", monitor = "DP-2", default = true })
hl.workspace_rule({ workspace = "3", monitor = "DP-1", default = true })
hl.workspace_rule({ workspace = "4", monitor = "DP-1", default = true })
hl.workspace_rule({ workspace = "5", monitor = "DP-1", default = true })
hl.workspace_rule({ workspace = "6", monitor = "DP-1", default = true })
hl.workspace_rule({ workspace = "7", monitor = "DP-1", default = true })
hl.workspace_rule({ workspace = "8", monitor = "DP-2", default = true })
hl.workspace_rule({ workspace = "9", monitor = "DP-1", default = true })
'
${pkgs.hyprland}/bin/hyprctl eval 'hl.dispatch(hl.dsp.focus({ monitor = "DP-2" })); hl.dispatch(hl.dsp.focus({ workspace = "2" }));'
''}"
"${pkgs.awww}/bin/awww restore"
(placeBar "desc:${aocB}")
];
};}
{profile = {
name = "valinor00";
outputs = [
{
criteria = "Lenovo Group Limited *";
position = "0,0";
}
];
exec = [
"${pkgs.writeShellScript "kanshi-hyprland-init" ''
#!/usr/bin/env bash
${pkgs.hyprland}/bin/hyprctl eval '
hl.workspace_rule({ workspace = "1", monitor = "eDP-1", default = true })
hl.workspace_rule({ workspace = "2", monitor = "eDP-1", default = true })
hl.workspace_rule({ workspace = "3", monitor = "eDP-1", default = true })
hl.workspace_rule({ workspace = "4", monitor = "eDP-1", default = true })
hl.workspace_rule({ workspace = "5", monitor = "eDP-1", default = true })
hl.workspace_rule({ workspace = "6", monitor = "eDP-1", default = true })
hl.workspace_rule({ workspace = "7", monitor = "eDP-1", default = true })
hl.workspace_rule({ workspace = "8", monitor = "eDP-1", default = true })
hl.workspace_rule({ workspace = "9", monitor = "eDP-1", default = true })
'
${pkgs.hyprland}/bin/hyprctl eval 'hl.dispatch(hl.dsp.focus({ monitor = "eDP-1" })); hl.dispatch(hl.dsp.focus({ workspace = "1" }));'
''}"
"${pkgs.awww}/bin/awww restore"
(placeBar "desc:Lenovo Group Limited")
];
};}
];
};
};
}