Tune waybar a bit, allow multi-monitor differences

This commit is contained in:
Natsu Kagami 2023-06-15 11:26:33 +02:00
parent d531f78075
commit 193f82f288
Signed by: nki
GPG key ID: 55A032EB38B49ADB
2 changed files with 172 additions and 158 deletions

View file

@ -64,6 +64,12 @@
}; };
nki.programs.kitty.enable = true; nki.programs.kitty.enable = true;
nki.programs.kitty.fontSize = 14; nki.programs.kitty.fontSize = 14;
programs.my-sway.waybar.makeBars = barWith: [
# For primary
(barWith { extraSettings = { output = [ "AOC U28G2G6B PPYP2JA000013" ]; }; })
# For secondary, hide mpd
(barWith { showMedia = false; showConnectivity = false; extraSettings = { output = [ "AOC 24G2W1G4 ATNN21A005410" ]; }; })
];
# Yellow light! # Yellow light!
services.wlsunset = { services.wlsunset = {

View file

@ -94,9 +94,14 @@ in
}; };
waybar = { waybar = {
makeBars = mkOption {
type = types.raw;
description = "Create bars with the barWith function, return a list of bars";
default = barWith: [ (barWith { }) ];
};
extraSettings = mkOption { extraSettings = mkOption {
type = types.attrs; type = types.raw;
description = "Additional settings for the default waybar"; description = "Extra settings to be included with every default bar";
default = { }; default = { };
}; };
extraStyle = mkOption { extraStyle = mkOption {
@ -367,12 +372,9 @@ in
]; ];
}; };
config.programs.waybar = mkIf cfg.enable { config.programs.waybar =
enable = true; let
systemd.enable = true; barWith = { showMedia ? true, showConnectivity ? true, extraSettings ? { }, ... }: (mkMerge [{
settings = [
# Top bar
(mkMerge [{
position = "top"; position = "top";
modules-left = [ modules-left = [
"sway/workspaces" "sway/workspaces"
@ -381,20 +383,20 @@ in
]; ];
modules-center = [ modules-center = [
]; ];
modules-right = [ modules-right =
(if cfg.enableMpd then "mpd" else "custom/media") lib.optional showMedia (if cfg.enableMpd then "mpd" else "custom/media")
++ [
"tray" "tray"
"pulseaudio" "pulseaudio"
] ++ lib.optionals showConnectivity [
"bluetooth" "bluetooth"
"network" "network"
] ++ [
"cpu" "cpu"
"memory" "memory"
"temperature" "temperature"
] ++ ( ] ++ lib.optionals cfg.enableLaptopBars [ "battery" "battery#bat2" ]
if cfg.enableLaptopBars ++ [
then [ "battery" "battery#bat2" ]
else [ ]
) ++ [
"clock" "clock"
]; ];
@ -409,13 +411,14 @@ in
max-length = 70; max-length = 70;
format = "{title}"; format = "{title}";
"rewrite" = { "rewrite" = {
"(.*) Mozilla Firefox" = "🌎 $1"; "(.*) Mozilla Firefox" = "[🌎] $1";
"(.*) - Kakoune" = "$1"; "(.*) - Mozilla Thunderbird" = "[📧] $1";
"(.*) - fish" = ">_ $1"; "(.*) - Kakoune" = "[] $1";
"(.*) - Discord" = "🗨 $1"; "(.*) - fish" = "[>_] $1";
"(.*) - Discord" = "[🗨] $1";
# ArmCord thing # ArmCord thing
" Discord \\| (.*)" = "🗨 $1"; " Discord \\| (.*)" = "[🗨] $1";
"\\((\\d+)\\) Discord \\| (.*)" = "🗨 [$1] $2"; "\\((\\d+)\\) Discord \\| (.*)" = "[🗨] {$1} $2";
}; };
}; };
"tray" = { "tray" = {
@ -534,8 +537,13 @@ in
}; };
}; };
} }
cfg.waybar.extraSettings]) cfg.waybar.extraSettings
]; extraSettings]);
in
mkIf cfg.enable {
enable = true;
systemd.enable = true;
settings = cfg.waybar.makeBars barWith;
style = '' style = ''
* { * {
border: none; border: none;