189 lines
7.8 KiB
Nix
189 lines
7.8 KiB
Nix
{
|
|
lib,
|
|
config,
|
|
pkgs,
|
|
...
|
|
}: let
|
|
cfg = config.myConfig.sway.kanshi;
|
|
in {
|
|
options.myConfig.sway.kanshi = {
|
|
enable = lib.mkEnableOption "kanshi, a dynamic display recognizer";
|
|
laptop = lib.mkEnableOption "laptop workspaces";
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
services.kanshi = let
|
|
bgdir = ../../../assets;
|
|
bg1080 = bgdir + "/bg1080.png";
|
|
bg1080vert = bgdir + "/bg1080vert.png";
|
|
bg4k = bgdir + "/bg4k.png";
|
|
luhbots_workstation = settings: {
|
|
profile.outputs = [
|
|
{
|
|
criteria = "eDP-1";
|
|
position = if settings.vertical.left then "1080,1080" else "0,1080";
|
|
}
|
|
{
|
|
criteria = settings.horizontal.name;
|
|
position = if settings.vertical.left then "1080,0" else "0,0";
|
|
}
|
|
{
|
|
criteria = settings.vertical.name;
|
|
transform = settings.vertical.orientation;
|
|
position = if settings.vertical.left then "0,0" else "1920,0";
|
|
}
|
|
];
|
|
profile.exec = [
|
|
"${pkgs.sway}/bin/swaymsg 'workspace \"main\" output \"${settings.horizontal.name}\", workspace --no-auto-back-and-forth main, move workspace to \"${settings.horizontal.name}\", workspace back_and_forth'"
|
|
"${pkgs.sway}/bin/swaymsg 'workspace \"term\" output \"${settings.vertical.name}\", workspace --no-auto-back-and-forth term, move workspace to \"${settings.vertical.name}\", workspace back_and_forth'"
|
|
"${pkgs.sway}/bin/swaymsg 'workspace \"msg\" output eDP-1, workspace --no-auto-back-and-forth msg, move workspace to eDP-1, workspace back_and_forth'"
|
|
"${pkgs.sway}/bin/swaymsg 'workspace \"msg\" output eDP-1, workspace --no-auto-back-and-forth music, move workspace to eDP-1, workspace back_and_forth'"
|
|
"${pkgs.sway}/bin/swaymsg 'workspace \"5\" output \"${settings.horizontal.name}\", workspace --no-auto-back-and-forth 5, move workspace to \"${settings.horizontal.name}\", workspace back_and_forth'"
|
|
"${pkgs.sway}/bin/swaymsg 'output \"eDP-1\" bg ${bg1080} fit'"
|
|
"${pkgs.sway}/bin/swaymsg 'output \"${settings.horizontal.name}\" bg ${bg4k} fit'"
|
|
"${pkgs.sway}/bin/swaymsg 'output \"${settings.vertical.name}\" bg ${bg1080vert} fit'"
|
|
"${pkgs.sway}/bin/swaymsg 'workspace --no-auto-back-and-forth msg, workspace --no-auto-back-and-forth term, workspace --no-auto-back-and-forth main'"
|
|
];
|
|
};
|
|
in {
|
|
enable = true;
|
|
settings = lib.mkIf cfg.laptop [
|
|
{
|
|
profile.name = "laptop";
|
|
profile.outputs = [
|
|
{
|
|
criteria = "eDP-1";
|
|
position = "0,0";
|
|
}
|
|
];
|
|
}
|
|
(luhbots_workstation {
|
|
horizontal.name = "Dell Inc. DELL U2422HE GRCPH83";
|
|
vertical = {
|
|
name = "NEC Corporation E243WMi 7X313185NB";
|
|
left = false;
|
|
orientation = "90";
|
|
};
|
|
})
|
|
(luhbots_workstation {
|
|
horizontal.name = "Dell Inc. DELL U2422HE 8YCPH83";
|
|
vertical = {
|
|
name = "Dell Inc. DELL P2422HE 28XL9M3";
|
|
left = false;
|
|
orientation = "normal";
|
|
};
|
|
})
|
|
(luhbots_workstation {
|
|
horizontal.name = "Dell Inc. DELL U2422HE 53DCH83";
|
|
vertical = {
|
|
name = "Dell Inc. DELL U2412M 0FFXD46I4U5S";
|
|
left = false;
|
|
orientation = "90";
|
|
};
|
|
})
|
|
(luhbots_workstation {
|
|
horizontal.name = "Dell Inc. DELL P2422HE 4BXL9M";
|
|
vertical = {
|
|
name = "NEC Corporation E243WMi 75309334NB";
|
|
left = true;
|
|
orientation = "90";
|
|
};
|
|
})
|
|
(luhbots_workstation {
|
|
horizontal.name = "Dell Inc. DELL P2422HE JLXL9M3";
|
|
vertical = {
|
|
name = "NEC Corporation E243WMi 59118576NB";
|
|
left = true;
|
|
orientation = "90";
|
|
};
|
|
})
|
|
(luhbots_workstation {
|
|
horizontal.name = "Dell Inc. DELL P2422HE 7VWL9M3";
|
|
vertical = {
|
|
name = "ViewSonic Corporation VG2448 V5E201960167";
|
|
left = false;
|
|
orientation = "90";
|
|
};
|
|
})
|
|
(luhbots_workstation {
|
|
horizontal.name = "Dell Inc. DELL U2422HE 7HCPH83";
|
|
vertical = {
|
|
name = "Dell Inc. DELL U2422HE 1XFFH83";
|
|
left = true;
|
|
orientation = "90";
|
|
};
|
|
})
|
|
(luhbots_workstation {
|
|
horizontal.name = "Dell Inc. DELL U2422HE 5XY5H83";
|
|
vertical = {
|
|
name = "Dell Inc. DELL U2419H 11B7Y13";
|
|
left = true;
|
|
orientation = "270";
|
|
};
|
|
})
|
|
{
|
|
profile.name = "docked-4k";
|
|
profile.outputs = [
|
|
{
|
|
criteria = "eDP-1";
|
|
position = "320,1440";
|
|
}
|
|
{
|
|
criteria = "HannStar Display Corp HC281UPB ";
|
|
position = "0,0";
|
|
mode = "3840x2160@60";
|
|
scale = 1.5;
|
|
}
|
|
];
|
|
profile.exec = [
|
|
"${pkgs.sway}/bin/swaymsg workspace main; move workspace to HDMI-A-1; workspace back_and_forth"
|
|
"${pkgs.sway}/bin/swaymsg workspace term; move workspace to eDP-1; workspace back_and_forth"
|
|
"${pkgs.sway}/bin/swaymsg workspace msg; move workspace to eDP-1; workspace back_and_forth"
|
|
"${pkgs.sway}/bin/swaymsg workspace music; move workspace to eDP-1; workspace back_and_forth"
|
|
"${pkgs.sway}/bin/swaymsg workspace 5; move workspace to HDMI-A-1; workspace back_and_forth"
|
|
];
|
|
}
|
|
{
|
|
profile.outputs = [
|
|
{
|
|
criteria = "eDP-1";
|
|
position = "0,0";
|
|
}
|
|
{
|
|
criteria = "Hisense Electric Co., Ltd. HISENSE 0x00000001";
|
|
position = "1920,0";
|
|
}
|
|
];
|
|
profile.exec = [
|
|
"${pkgs.sway}/bin/swaymsg workspace --no-auto-back-and-forth main; move workspace to eDP-1; workspace back_and_forth"
|
|
"${pkgs.sway}/bin/swaymsg workspace --no-auto-back-and-forth term; move workspace to eDP-1; workspace back_and_forth"
|
|
"${pkgs.sway}/bin/swaymsg workspace --no-auto-back-and-forth msg; move workspace to eDP-1; workspace back_and_forth"
|
|
"${pkgs.sway}/bin/swaymsg workspace --no-auto-back-and-forth music; move workspace to eDP-1; workspace back_and_forth"
|
|
"${pkgs.sway}/bin/swaymsg workspace --no-auto-back-and-forth 5; move workspace to eDP-1; workspace back_and_forth"
|
|
"${pkgs.sway}/bin/swaymsg workspace --no-auto-back-and-forth mirror; move workspace to HDMI-A-1; exec ${pkgs.wl-mirror}/bin/wl-mirror eDP-1; workspace back_and_forth"
|
|
];
|
|
}
|
|
{
|
|
profile.outputs = [
|
|
{
|
|
criteria = "eDP-1";
|
|
position = "0,1080";
|
|
}
|
|
{
|
|
criteria = "ViewSonic Corporation VG2448 V5E201864188";
|
|
position = "0,0";
|
|
}
|
|
];
|
|
profile.exec = [
|
|
"${pkgs.sway}/bin/swaymsg workspace --no-auto-back-and-forth main; move workspace to '\"ViewSonic Corporation VG2448 V5E201864188\"'; workspace back_and_forth"
|
|
"${pkgs.sway}/bin/swaymsg workspace --no-auto-back-and-forth term; move workspace to eDP-1; workspace back_and_forth"
|
|
"${pkgs.sway}/bin/swaymsg workspace --no-auto-back-and-forth msg; move workspace to eDP-1; workspace back_and_forth"
|
|
"${pkgs.sway}/bin/swaymsg workspace --no-auto-back-and-forth music; move workspace to eDP-1; workspace back_and_forth"
|
|
"${pkgs.sway}/bin/swaymsg workspace --no-auto-back-and-forth 5; move workspace to '\"ViewSonic Corporation VG2448 V5E201864188\"'; workspace back_and_forth"
|
|
];
|
|
}
|
|
];
|
|
};
|
|
};
|
|
}
|