Update kanshi to use settings instead of profiles

Add kanshi config to Northstar

Standardise monitor config across machines

Move waybar alt bar definition to Vanguard config specifically, don't
need to use hacky solution
This commit is contained in:
Evie Litherland-Smith 2024-06-15 09:57:26 +01:00
parent e869e866f1
commit 8f179c9f6b
6 changed files with 303 additions and 269 deletions

View file

@ -1,8 +1,42 @@
{...}: { {...}: {
imports = [./default.nix]; imports = [./default.nix];
wayland.windowManager.sway.config.output = { wayland.windowManager.sway.config = let
"eDP-1" = { defaultOutput = "eDP-1";
scale = "1.25"; in {
}; output.${defaultOutput}.scale = "1.25";
workspaceOutputAssign = [
{
output = defaultOutput;
workspace = "1";
}
];
};
services.kanshi = {
enable = true;
settings = let
laptopScreen = {
criteria = "eDP-1";
scale = 1.25;
position = "3000,636";
};
monitor1 = {
criteria = "Acer Technologies ED270R TJMEE0043W01";
mode = "1920x1080@165Hz";
position = "1080,420";
};
monitor2 = {
criteria = "Ancor Communications Inc VS278 FALMQS032358";
position = "0,0";
transform = "270";
};
in [
{output = laptopScreen;}
{
profile = {
name = "docked";
outputs = [laptopScreen monitor1 monitor2];
};
}
];
}; };
} }

View file

@ -1,9 +1,6 @@
{...}: { {...}: {
imports = [./work.nix]; imports = [./work.nix];
wayland.windowManager.sway.config.output = { wayland.windowManager.sway.config = {
"Dell Inc. DELL P3223QE CCG8YN3" = { output."Dell Inc. DELL P3223QE CCG8YN3".scale = "1.5";
pos = "0 0";
scale = "1.5";
};
}; };
} }

View file

@ -1,34 +1,37 @@
{...}: { {...}: {
imports = [./work.nix]; imports = [./work.nix];
wayland.windowManager.sway.config.output = { wayland.windowManager.sway.config = let
"eDP-1" = { defaultOutput = "eDP-1";
scale = "1.25"; in {
position = "2560 576"; output.${defaultOutput}.scale = "1.25";
}; workspaceOutputAssign = [
"Dell Inc. DELL P3223QE CCG8YN3" = { {
scale = "1.5"; output = defaultOutput;
position = "0 0"; workspace = "1";
}; }
];
}; };
services.kanshi = { services.kanshi = {
enable = true; enable = true;
systemdTarget = "sway-session.target"; settings = let
profiles = let
laptopScreen = { laptopScreen = {
criteria = "eDP-1"; criteria = "eDP-1";
status = "enable"; scale = 1.25;
position = "2560,576";
}; };
monitor = { monitor = {
criteria = "Dell Inc. DELL P3223QE CCG8YN3"; criteria = "Dell Inc. DELL P3223QE CCG8YN3";
status = "enable"; scale = 1.5;
position = "0,0";
}; };
in { in [
undocked = { {output = laptopScreen;}
outputs = [laptopScreen]; {
}; profile = {
docked = { name = "docked";
outputs = [monitor laptopScreen]; outputs = [laptopScreen monitor];
}; };
}; }
];
}; };
} }

View file

@ -1,4 +1,8 @@
{pkgs, ...}: { {
config,
pkgs,
...
}: {
imports = [ imports = [
./default.nix ./default.nix
../programs/games/default.nix ../programs/games/default.nix
@ -8,30 +12,39 @@
freecad freecad
prusa-slicer prusa-slicer
]; ];
wayland.windowManager.sway.config = { wayland.windowManager.sway.config = let
startup = [ defaultOutput = "DP-2";
{command = "${pkgs.xorg.xrandr}/bin/xrandr --output DP-2 --primary";} in {
];
output = { output = {
"Acer Technologies ED270R TJMEE0043W01" = { "Acer Technologies ED270R TJMEE0043W01" = {
mode = "1920x1080@165Hz"; mode = "1920x1080@165Hz";
pos = "1080 420"; position = "1080 420";
adaptive_sync = "off"; adaptive_sync = "off";
}; };
"Ancor Communications Inc VS278 FALMQS032358" = { "Ancor Communications Inc VS278 FALMQS032358" = {
pos = "0 0"; position = "0 0";
transform = "270"; transform = "270";
}; };
}; };
workspaceOutputAssign = [ workspaceOutputAssign = [
{ {
output = "HDMI-A-1"; output = defaultOutput;
workspace = "1"; workspace = "1";
} }
]; ];
startup = [
{command = "${pkgs.xorg.xrandr}/bin/xrandr --output ${defaultOutput} --primary";}
];
}; };
programs.waybar.settings = { programs.waybar.settings = {
main.output = ["DP-2"]; main.output = ["DP-2"];
alt.output = ["HDMI-A-1"]; alt = {
inherit (config.programs.waybar.settings.main) layer position "sway/workspaces";
name = "alt";
output = ["HDMI-A-1"];
"modules-left" = [];
"modules-center" = ["sway/workspaces"];
"modules-right" = [];
};
}; };
} }

View file

@ -7,6 +7,8 @@
accentColour2, accentColour2,
... ...
}: { }: {
programs.waybar.systemd.target = lib.mkIf config.wayland.windowManager.sway.systemd.enable "sway-session.target";
services.kanshi.systemdTarget = lib.mkIf config.wayland.windowManager.sway.systemd.enable "sway-session.target";
wayland.windowManager.sway = { wayland.windowManager.sway = {
enable = true; enable = true;
package = package =

View file

@ -1,8 +1,6 @@
{ {
config, config,
lib,
pkgs, pkgs,
hostname,
fonts, fonts,
accentColour, accentColour,
... ...
@ -13,237 +11,224 @@
}; };
programs.waybar = { programs.waybar = {
enable = true; enable = true;
systemd = { systemd.enable = true;
enable = true; settings.main = {
target = "sway-session.target"; name = "main";
}; layer = "top";
settings = rec { position = "bottom";
main = { # Layout
name = "main"; "modules-left" = [
layer = "top"; "sway/workspaces"
position = "bottom"; "sway/window"
# Layout ];
"modules-left" = [ "modules-center" = [];
"sway/workspaces" "modules-right" = [
"sway/window" "mpris"
]; "custom/notification"
"modules-center" = []; "pulseaudio"
"modules-right" = [ "network"
"mpris" "bluetooth"
"custom/notification" "clock#calendar"
"pulseaudio" "clock"
"network" "backlight"
"bluetooth" "battery"
"clock#calendar" "custom/weather"
"clock" "tray"
"backlight" ];
"battery" # Module config
"custom/weather" "sway/workspaces" = {
"tray" format = "{icon}";
]; format-icons = {
# Module config "1" = "󰫃 ";
"sway/workspaces" = { "2" = "󰫄 ";
format = "{icon}"; "3" = "󰫅 ";
format-icons = { "4" = "󰫆 ";
"1" = "󰫃 "; "5" = "󰫇 ";
"2" = "󰫄 "; "6" = "󰫈 ";
"3" = "󰫅 "; default = "󰋙 ";
"4" = "󰫆 "; urgent = "󰁡 ";
"5" = "󰫇 ";
"6" = "󰫈 ";
default = "󰋙 ";
urgent = "󰁡 ";
};
# show-special = false;
# sort-by-number = true;
all-outputs = false;
persistent-workspaces = {
"1" = [];
"2" = [];
"3" = [];
"4" = [];
"5" = [];
"6" = [];
};
}; };
"sway/window" = { # show-special = false;
"format" = "{title}"; # sort-by-number = true;
"max-length" = 50; all-outputs = false;
"rewrite" = { persistent-workspaces = {
"(.*) - GNU Emacs at (.*)" = " $1 [$2]"; "1" = [];
"(alacritty.*)" = " $1"; "2" = [];
"(foot.*)" = " $1"; "3" = [];
"(.*) - mpv" = "󰦟 $1"; "4" = [];
"swayimg: (.*)" = "󰋩 $1"; "5" = [];
"(btm)" = " Resource Usage [$1]"; "6" = [];
"(cava)" = "󰝚 Music Visualiser [$1]";
"(.*) - Thunar" = "󰝰 $1";
"Mozilla Firefox" = "󰈹 $1";
"(.*) Mozilla Firefox" = "󰈹 $1";
"Nyxt - (.*)" = "󰀹 $1";
"(.*) - Chromium" = "󰊯 $1";
"(Signal.*)" = "󰭹 $1";
"((?:.*)WebCord.*)" = "󰙯 $1";
"(Cartridges.*)" = "󰊗 $1";
"([Ss]team.*)" = "󰓓 $1";
"(Prism Launcher.*)" = "󰍳 Minecraft ($1)";
"(X2Go Client)" = "󰢹 $1";
"(NoMachine|Nxplayer.bin) (.*)" = "󰢹 $1 $2";
};
};
mpris = {
"format" = "{status_icon} {player_icon} {artist} - {title}";
"tooltip-format" = "{player_icon} ({player}) {dynamic}";
"title-len" = 64;
"interval" = 1;
"dynamic-order" = [
"album"
"artist"
"title"
"position"
"length"
];
"player-icons" = {
"default" = "󰲸 ";
"emms" = " ";
"firefox" = "󰈹 ";
"mpv" = "󰦟 ";
};
"status-icons" = {
"playing" = "󰐊";
"paused" = "󰏤";
"stopped" = "󰓛";
};
"ignored-players" = [];
};
pulseaudio = {
scroll-step = 5;
format = "{format_source}{icon}{volume}%";
format-muted = "{format_source} 󰝟 ";
format-source = "󰍬 ";
format-source-muted = "󰍭 ";
format-icons = {
car = "󰄍 ";
default = ["󰕿 " "󰖀 " "󰕾 "];
hands-free = "󰥰 ";
headset = "󰋎 ";
phone = "󰏲 ";
portable = "󰏳 ";
headphone = "󰋋 ";
};
on-click = "${pkgs.pavucontrol}/bin/pavucontrol";
on-click-right = "${pkgs.pamixer}/bin/pamixer -t";
on-scroll-up = "${pkgs.pamixer}/bin/pamixer -i 5";
on-scroll-down = "${pkgs.pamixer}/bin/pamixer -d 5";
};
disk = {
format = "󰋊 {percentage_used}%";
path = config.home.homeDirectory;
};
cpu = {
format = "󰻠 {usage}%";
tooltip = false;
};
memory = {format = "󰍛 {}%";};
temperature = {
critical-threshold = 80;
format = "{icon} {temperatureC}°C";
format-icons = ["󱃃" "󰔏" "󱃂"];
};
network = {
format-icons = ["󰤟 " "󰤢 " "󰤥 " "󰤨 "];
format-wifi = "{icon}";
format-ethernet = "󰈁 ";
tooltip-format = "{essid} ({signalStrength}%)";
format-linked = "󰈂 ";
format-disconnected = "󰈂 ";
};
bluetooth = {
format = "󰂯";
format-disabled = "󰂲";
format-off = "󰂲";
format-on = "󰂯";
format-connected = "󰂱";
tooltip-format = "{status} | {device_alias}";
on-click = "${pkgs.bluez}/bin/bluetoothctl power on";
on-click-right = "${pkgs.bluez}/bin/bluetoothctl power off";
};
"clock#calendar" = {
# format = "{:󰃭 %Y-%m-%d}";
format = "{:%Y-%m-%d}"; # TEMP, see https://github.com/Alexays/Waybar/issues/3021
tooltip-format = "<tt><small>{calendar}</small></tt>";
calendar = {
mode = "month";
mode-mon-col = 3;
weeks-pos = "left";
on-scroll = 1;
on-click-right = "mode";
format = {
months = "<span color='#ffead3'><b>{}</b></span>";
days = "<span color='#ecc6d9'><b>{}</b></span>";
weeks = "<span color='#99ffdd'><b>W{}</b></span>";
weekdays = "<span color='#ffcc66'><b>{}</b></span>";
today = "<span color='#ff6699'><b><u>{}</u></b></span>";
};
};
actions = {
on-click-right = "mode";
on-scroll-up = "shift_up";
on-scroll-down = "shift_down";
};
};
clock = {
# format = "{:󰥔 %R}";
format = "{:%R}"; # TEMP, see https://github.com/Alexays/Waybar/issues/3021
};
backlight = {
format = "{icon}";
tooltip-format = "{percent}%";
format-icons = [" " " " " " " " " " " " " " " " " "];
};
battery = {
states = {
warning = 30;
critical = 20;
};
format = "{icon}";
format-charging = "󰂄 ";
format-plugged = "󰚥 ";
tooltip-format = "{capacity}% {time}";
format-icons = ["󱃍 " "󰁺 " "󰁻 " "󰁼 " "󰁽 " "󰁾 " "󰁿 " "󰂀 " "󰂁 " "󰂂 " "󰁹 "];
};
"custom/notification" = let
makoctl = "${pkgs.mako}/bin/makoctl";
jq = "${pkgs.jq}/bin/jq";
in {
exec = "( ${makoctl} list | ${jq} -e '.data[] | length > 0' >/dev/null && echo '󱅫 ' ) || echo '󰂚 ' ";
format = "{}";
on-click = "${makoctl} dismiss -a";
interval = 3;
};
"custom/weather" = let
date-format = "%Y-%m-%d";
custom-indicator = "{ICON}{temp_C}({FeelsLikeC})";
in {
format = "{}°";
tooltip = true;
interval = 900; # Every 15 minutes
exec = ''${pkgs.wttrbar}/bin/wttrbar --location Didcot --date-format "${date-format}" --custom-indicator "${custom-indicator}"'';
return-type = "json";
};
tray = {
icon-size = builtins.floor fonts.sizes.popups;
show-passive-items = true;
spacing = 5;
}; };
}; };
# TEMP FIX "sway/window" = {
alt = lib.mkIf (hostname == "Vanguard") { "format" = "{title}";
inherit (main) layer position "sway/workspaces"; "max-length" = 50;
name = "alt"; "rewrite" = {
"modules-left" = []; "(.*) - GNU Emacs at (.*)" = " $1 [$2]";
"modules-center" = ["sway/workspaces"]; "(alacritty.*)" = " $1";
"modules-right" = []; "(foot.*)" = " $1";
"(.*) - mpv" = "󰦟 $1";
"swayimg: (.*)" = "󰋩 $1";
"(btm)" = " Resource Usage [$1]";
"(cava)" = "󰝚 Music Visualiser [$1]";
"(.*) - Thunar" = "󰝰 $1";
"Mozilla Firefox" = "󰈹 $1";
"(.*) Mozilla Firefox" = "󰈹 $1";
"Nyxt - (.*)" = "󰀹 $1";
"(.*) - Chromium" = "󰊯 $1";
"(Signal.*)" = "󰭹 $1";
"((?:.*)WebCord.*)" = "󰙯 $1";
"(Cartridges.*)" = "󰊗 $1";
"([Ss]team.*)" = "󰓓 $1";
"(Prism Launcher.*)" = "󰍳 Minecraft ($1)";
"(X2Go Client)" = "󰢹 $1";
"(NoMachine|Nxplayer.bin) (.*)" = "󰢹 $1 $2";
};
};
mpris = {
"format" = "{status_icon} {player_icon} {artist} - {title}";
"tooltip-format" = "{player_icon} ({player}) {dynamic}";
"title-len" = 64;
"interval" = 1;
"dynamic-order" = [
"album"
"artist"
"title"
"position"
"length"
];
"player-icons" = {
"default" = "󰲸 ";
"emms" = " ";
"firefox" = "󰈹 ";
"mpv" = "󰦟 ";
};
"status-icons" = {
"playing" = "󰐊";
"paused" = "󰏤";
"stopped" = "󰓛";
};
"ignored-players" = [];
};
pulseaudio = {
scroll-step = 5;
format = "{format_source}{icon}{volume}%";
format-muted = "{format_source} 󰝟 ";
format-source = "󰍬 ";
format-source-muted = "󰍭 ";
format-icons = {
car = "󰄍 ";
default = ["󰕿 " "󰖀 " "󰕾 "];
hands-free = "󰥰 ";
headset = "󰋎 ";
phone = "󰏲 ";
portable = "󰏳 ";
headphone = "󰋋 ";
};
on-click = "${pkgs.pavucontrol}/bin/pavucontrol";
on-click-right = "${pkgs.pamixer}/bin/pamixer -t";
on-scroll-up = "${pkgs.pamixer}/bin/pamixer -i 5";
on-scroll-down = "${pkgs.pamixer}/bin/pamixer -d 5";
};
disk = {
format = "󰋊 {percentage_used}%";
path = config.home.homeDirectory;
};
cpu = {
format = "󰻠 {usage}%";
tooltip = false;
};
memory = {format = "󰍛 {}%";};
temperature = {
critical-threshold = 80;
format = "{icon} {temperatureC}°C";
format-icons = ["󱃃" "󰔏" "󱃂"];
};
network = {
format-icons = ["󰤟 " "󰤢 " "󰤥 " "󰤨 "];
format-wifi = "{icon}";
format-ethernet = "󰈁 ";
tooltip-format = "{essid} ({signalStrength}%)";
format-linked = "󰈂 ";
format-disconnected = "󰈂 ";
};
bluetooth = {
format = "󰂯";
format-disabled = "󰂲";
format-off = "󰂲";
format-on = "󰂯";
format-connected = "󰂱";
tooltip-format = "{status} | {device_alias}";
on-click = "${pkgs.bluez}/bin/bluetoothctl power on";
on-click-right = "${pkgs.bluez}/bin/bluetoothctl power off";
};
"clock#calendar" = {
# format = "{:󰃭 %Y-%m-%d}";
format = "{:%Y-%m-%d}"; # TEMP, see https://github.com/Alexays/Waybar/issues/3021
tooltip-format = "<tt><small>{calendar}</small></tt>";
calendar = {
mode = "month";
mode-mon-col = 3;
weeks-pos = "left";
on-scroll = 1;
on-click-right = "mode";
format = {
months = "<span color='#ffead3'><b>{}</b></span>";
days = "<span color='#ecc6d9'><b>{}</b></span>";
weeks = "<span color='#99ffdd'><b>W{}</b></span>";
weekdays = "<span color='#ffcc66'><b>{}</b></span>";
today = "<span color='#ff6699'><b><u>{}</u></b></span>";
};
};
actions = {
on-click-right = "mode";
on-scroll-up = "shift_up";
on-scroll-down = "shift_down";
};
};
clock = {
# format = "{:󰥔 %R}";
format = "{:%R}"; # TEMP, see https://github.com/Alexays/Waybar/issues/3021
};
backlight = {
format = "{icon}";
tooltip-format = "{percent}%";
format-icons = [" " " " " " " " " " " " " " " " " "];
};
battery = {
states = {
warning = 30;
critical = 20;
};
format = "{icon}";
format-charging = "󰂄 ";
format-plugged = "󰚥 ";
tooltip-format = "{capacity}% {time}";
format-icons = ["󱃍 " "󰁺 " "󰁻 " "󰁼 " "󰁽 " "󰁾 " "󰁿 " "󰂀 " "󰂁 " "󰂂 " "󰁹 "];
};
"custom/notification" = let
makoctl = "${pkgs.mako}/bin/makoctl";
jq = "${pkgs.jq}/bin/jq";
in {
exec = "( ${makoctl} list | ${jq} -e '.data[] | length > 0' >/dev/null && echo '󱅫 ' ) || echo '󰂚 ' ";
format = "{}";
on-click = "${makoctl} dismiss -a";
interval = 3;
};
"custom/weather" = let
date-format = "%Y-%m-%d";
custom-indicator = "{ICON}{temp_C}({FeelsLikeC})";
in {
format = "{}°";
tooltip = true;
interval = 900; # Every 15 minutes
exec = ''${pkgs.wttrbar}/bin/wttrbar --location Didcot --date-format "${date-format}" --custom-indicator "${custom-indicator}"'';
return-type = "json";
};
tray = {
icon-size = builtins.floor fonts.sizes.popups;
show-passive-items = true;
spacing = 5;
}; };
}; };
style = with config.scheme.withHashtag; let style = with config.scheme.withHashtag; let