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,22 +383,22 @@ 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" ++ [
"pulseaudio" "tray"
"bluetooth" "pulseaudio"
"network" ] ++ lib.optionals showConnectivity [
"cpu" "bluetooth"
"memory" "network"
"temperature" ] ++ [
] ++ ( "cpu"
if cfg.enableLaptopBars "memory"
then [ "battery" "battery#bat2" ] "temperature"
else [ ] ] ++ lib.optionals cfg.enableLaptopBars [ "battery" "battery#bat2" ]
) ++ [ ++ [
"clock" "clock"
]; ];
modules = { modules = {
"sway/workspaces" = { "sway/workspaces" = {
@ -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,163 +537,168 @@ in
}; };
}; };
} }
cfg.waybar.extraSettings]) cfg.waybar.extraSettings
]; extraSettings]);
style = '' in
* { mkIf cfg.enable {
border: none; enable = true;
border-radius: 0; systemd.enable = true;
font-family: IBM Plex Mono, 'Font Awesome 5', 'Symbols Nerd Font Mono', 'SFNS Display', Helvetica, Arial, sans-serif; settings = cfg.waybar.makeBars barWith;
font-size: ${toString cfg.fontSize}px; style = ''
min-height: 0; * {
} border: none;
border-radius: 0;
font-family: IBM Plex Mono, 'Font Awesome 5', 'Symbols Nerd Font Mono', 'SFNS Display', Helvetica, Arial, sans-serif;
font-size: ${toString cfg.fontSize}px;
min-height: 0;
}
window#waybar { window#waybar {
background: rgba(43, 48, 59, 0.5); background: rgba(43, 48, 59, 0.5);
border-bottom: 3px solid rgba(100, 114, 125, 0.5); border-bottom: 3px solid rgba(100, 114, 125, 0.5);
color: #ffffff; color: #ffffff;
} }
window#waybar.hidden { window#waybar.hidden {
opacity: 0.0; opacity: 0.0;
} }
/* https://github.com/Alexays/Waybar/wiki/FAQ#the-workspace-buttons-have-a-strange-hover-effect */ /* https://github.com/Alexays/Waybar/wiki/FAQ#the-workspace-buttons-have-a-strange-hover-effect */
#workspaces button { #workspaces button {
padding: 0 5px; padding: 0 5px;
background: transparent; background: transparent;
color: #ffffff; color: #ffffff;
border-bottom: 3px solid transparent; border-bottom: 3px solid transparent;
} }
#workspaces button.focused { #workspaces button.focused {
background: #64727D; background: #64727D;
border-bottom: 3px solid #ffffff; border-bottom: 3px solid #ffffff;
} }
#workspaces button.urgent { #workspaces button.urgent {
background-color: #eb4d4b; background-color: #eb4d4b;
} }
#window, #sway, #sway-window { #window, #sway, #sway-window {
padding: 0 10px; padding: 0 10px;
} }
#mode { #mode {
background: #64727D; background: #64727D;
border-bottom: 3px solid #ffffff; border-bottom: 3px solid #ffffff;
} }
#clock, #battery, #cpu, #memory, #temperature, #backlight, #network, #pulseaudio, #bluetooth, #custom-media, #tray, #mode, #idle_inhibitor, #mpd { #clock, #battery, #cpu, #memory, #temperature, #backlight, #network, #pulseaudio, #bluetooth, #custom-media, #tray, #mode, #idle_inhibitor, #mpd {
padding: 0 10px; padding: 0 10px;
margin: 0 5px; margin: 0 5px;
} }
#clock { #clock {
background-color: #64727D; background-color: #64727D;
} }
#battery { #battery {
background-color: #ffffff; background-color: #ffffff;
color: #000000; color: #000000;
} }
#battery.charging { #battery.charging {
color: #ffffff; color: #ffffff;
background-color: #26A65B; background-color: #26A65B;
} }
@keyframes blink { @keyframes blink {
to { to {
background-color: #ffffff; background-color: #ffffff;
color: #000000; color: #000000;
} }
} }
#battery.critical:not(.charging) { #battery.critical:not(.charging) {
background: #f53c3c; background: #f53c3c;
color: #ffffff; color: #ffffff;
animation-name: blink; animation-name: blink;
animation-duration: 0.5s; animation-duration: 0.5s;
animation-timing-function: linear; animation-timing-function: linear;
animation-iteration-count: infinite; animation-iteration-count: infinite;
animation-direction: alternate; animation-direction: alternate;
} }
#cpu { #cpu {
background: #2ecc71; background: #2ecc71;
color: #000000; color: #000000;
} }
#memory { #memory {
background: #9b59b6; background: #9b59b6;
} }
#backlight { #backlight {
background: #90b1b1; background: #90b1b1;
} }
#network { #network {
background: #2980b9; background: #2980b9;
} }
#network.disconnected { #network.disconnected {
background: #f53c3c; background: #f53c3c;
} }
#pulseaudio { #pulseaudio {
background: #f1c40f; background: #f1c40f;
color: #000000; color: #000000;
} }
#pulseaudio.muted { #pulseaudio.muted {
background: #90b1b1; background: #90b1b1;
} }
#bluetooth { #bluetooth {
background: DarkSlateBlue; background: DarkSlateBlue;
color: white; color: white;
} }
#custom-media { #custom-media {
background: #66cc99; background: #66cc99;
color: #2a5c45; color: #2a5c45;
} }
.custom-spotify { .custom-spotify {
background: #66cc99; background: #66cc99;
} }
.custom-vlc { .custom-vlc {
background: #ffa000; background: #ffa000;
} }
#temperature { #temperature {
background: #f0932b; background: #f0932b;
} }
#temperature.critical { #temperature.critical {
background: #eb4d4b; background: #eb4d4b;
} }
#tray { #tray {
background-color: #2980b9; background-color: #2980b9;
} }
#idle_inhibitor { #idle_inhibitor {
background-color: #2d3436; background-color: #2d3436;
} }
#idle_inhibitor.activated { #idle_inhibitor.activated {
background-color: #ecf0f1; background-color: #ecf0f1;
color: #2d3436; color: #2d3436;
} }
#mpd { #mpd {
background-color: teal; background-color: teal;
color: white; color: white;
} }
'' + cfg.waybar.extraStyle; '' + cfg.waybar.extraStyle;
}; };
config.home.packages = mkIf cfg.enable (with pkgs; [ config.home.packages = mkIf cfg.enable (with pkgs; [
# Needed for QT_QPA_PLATFORM # Needed for QT_QPA_PLATFORM
qt5.qtwayland qt5.qtwayland