Files
nixos-config/user/sweetbread/modules/waybar.nix
T

353 lines
8.4 KiB
Nix
Raw Normal View History

2026-04-07 22:40:16 +03:00
{ osConfig, config, pkgs, lib, ... }: {
home.packages = with pkgs; [
playerctl
cava
pulsemixer
2026-07-08 19:18:37 +03:00
libnotify
2026-06-03 17:56:40 +03:00
monocraft
font-awesome
nerd-fonts.symbols-only
2026-04-07 22:40:16 +03:00
];
2026-03-13 00:06:32 +03:00
2026-07-08 19:18:37 +03:00
programs.waybar = let
multibat = osConfig.networking.hostName == "Inaho";
in {
2026-04-07 22:40:16 +03:00
enable = true;
systemd.enable = true;
2026-03-13 00:06:32 +03:00
2026-04-07 22:40:16 +03:00
settings.mainBar = {
spacing = 8;
2026-03-13 00:06:32 +03:00
2026-04-07 22:40:16 +03:00
modules-left = [
"hyprland/workspaces"
"hyprland/language"
"keyboard-state"
"cava"
];
2026-03-13 00:06:32 +03:00
2026-04-07 22:40:16 +03:00
modules-center = [
"mpris"
];
2026-03-13 00:06:32 +03:00
2026-04-07 22:40:16 +03:00
modules-right = [
"tray"
"group/system"
"pulseaudio"
2026-07-08 19:18:37 +03:00
( if multibat then "group/bat" else "battery" )
2026-04-07 22:40:16 +03:00
"clock"
];
2026-03-13 00:06:32 +03:00
2026-04-07 22:40:16 +03:00
cava = {
bars = 14;
sleep_timer = 5;
hide_on_silence = true;
bar_delimiter = 0;
input_delay = 0;
format-icons = [" " "▁" "▂" "▃" "▄" "▅" "▆" "▇" "█"];
};
2026-03-13 00:06:32 +03:00
2026-04-07 22:40:16 +03:00
clock = {
tooltip = false;
interval = 5;
format = "{:L%d %b - %H:%M %a}";
};
2026-03-13 00:06:32 +03:00
2026-04-07 22:40:16 +03:00
pulseaudio = {
2026-06-03 17:56:40 +03:00
format = "{icon} {volume}%";
2026-04-07 22:40:16 +03:00
format-icons = {
headphone = "";
hands-free = "";
headset = "";
phone = "";
phone-muted = "";
portable = "";
car = "";
default = ["" ""];
};
on-click = "ghostty --title=pulsemixer -e pulsemixer";
};
2026-03-13 00:06:32 +03:00
2026-04-07 22:40:16 +03:00
mpris = {
format = "{dynamic}";
dynamic-len = if osConfig.host.laptop then 32 else 64;
dynamic-order = [ "title" "artist" "album" ];
};
2026-07-08 19:18:37 +03:00
"group/bat" = lib.mkIf multibat {
orientation = "inherit";
drawer = {
transition-duration = 500;
transition-left-to-right = false;
};
modules = [
"battery"
"battery#int"
"battery#ext"
];
};
2026-04-07 22:40:16 +03:00
battery = {
interval = 5;
states = {
warning = 30;
critical = 15;
};
format = "{icon} {capacity}%";
format-icons = {
default = ["󰂎" "󰁺" "󰁻" "󰁼" "󰁽" "󰁾" "󰁿" "󰂀" "󰂁" "󰂂" "󰁹"];
charging = ["󰢟" "󰢜" "󰂆" "󰂇" "󰂈" "󰢝" "󰂉" "󰢞" "󰂊" "󰂋" "󰂅"];
};
2026-07-08 19:18:37 +03:00
events = {
on-discharging-warning = "notify-send -u normal 'Low Battery'";
on-discharging-critical = "notify-send -u critical 'Very Low Battery'";
};
};
"battery#int" = lib.mkIf multibat {
bat = "BAT0";
interval = 5;
states = {
warning = 30;
critical = 15;
};
format = "I: {capacity}%";
};
"battery#ext" = lib.mkIf multibat {
bat = "BAT1";
interval = 5;
states = {
warning = 30;
critical = 15;
};
format = "E: {capacity}%";
events = {
on-discharging-critical = "notify-send -u normal 'External battery is critical";
};
2026-04-07 22:40:16 +03:00
};
"keyboard-state" = {
capslock = true;
format = "{icon}";
format-icons = {
locked = "CAPS";
unlocked = "";
};
};
"hyprland/language" = {
format-en = "en";
format-ru = "ru";
};
"group/system" = {
orientation = "inherit";
drawer = {
transition-duration = 500;
transition-left-to-right = false;
};
modules = [
"network"
"custom/mem"
"cpu"
"temperature"
];
};
network = {
format = "{ifname}";
format-wifi = " {essid} ({signalStrength}%)";
format-ethernet = "{ifname}";
format-disconnected = "";
tooltip-format = "{ipaddr}";
max-length = 50;
2026-07-09 02:48:20 +03:00
on-click = "ghostty --title=wifitui -e wifitui";
2026-04-07 22:40:16 +03:00
};
"custom/weather" = {
format = "{}";
tooltip = true;
interval = 1800;
exec = "python3 $HOME/.config/waybar/scripts/wttr.py";
return-type = "json";
};
"custom/mem" = {
format = "{} ";
interval = 3;
exec = "free -h | awk '/Mem:/{printf $3}'";
tooltip = false;
};
cpu = {
interval = 2;
format = "{usage}% ";
min-length = 6;
};
temperature = {
hwmon-path = "/sys/class/hwmon/hwmon5/temp1_input";
critical-threshold = 80;
format = "{temperatureC}°C {icon}";
format-icons = ["" "" "" "" ""];
tooltip = false;
};
};
style = let
colors = config.lib.stylix.colors.withHashtag;
2026-06-08 03:24:54 +03:00
accent = colors.${config.stylix.accent};
2026-04-07 22:40:16 +03:00
radius = "6px";
scssFile = pkgs.writeText "waybar.scss" /*scss*/ ''
window#waybar {
background: transparent;
color: ${colors.base05};
2026-03-13 00:06:32 +03:00
border-radius: ${radius};
2026-06-03 17:56:40 +03:00
font-family: "Symbols Nerd Font Mono", "Monocraft", "Font Awesome 7 Free";
2026-04-07 22:40:16 +03:00
font-weight: bold;
font-size: .85em;
& > * { padding: 8px; }
}
#cava,
#language,
#mpris,
#pulseaudio,
#network,
#battery,
#cpu,
#temperature,
#keyboard-state label.locked,
#custom-mem,
#clock {
background: ${colors.base00};
border-radius: ${radius};
padding: 8px;
}
#workspaces,
#tray {
background: ${colors.base00};
border-radius: ${radius};
}
#workspaces button {
color: ${colors.base05};
padding: 4px;
border-radius: ${radius};
border: 1pt solid transparent;
2026-03-13 00:06:32 +03:00
&:hover { background: ${colors.base01}; }
2026-04-07 22:40:16 +03:00
&.active {
2026-06-08 03:24:54 +03:00
background: ${accent};
2026-03-13 00:06:32 +03:00
color: ${colors.base00};
2026-04-07 22:40:16 +03:00
&:hover {
2026-06-08 03:24:54 +03:00
border-color: ${accent};
2026-04-07 22:40:16 +03:00
background: ${colors.base01};
2026-06-08 03:24:54 +03:00
color: ${accent};
2026-04-07 22:40:16 +03:00
}
}
}
#mpris {
&:hover { background: ${colors.base01}; }
&.paused { opacity: .5; }
}
#tray {
widget {
border: 1pt solid transparent;
border-radius: ${radius};
&:hover { background: ${colors.base01}; }
& > image { padding: 8px; }
}
& > .passive { border-color: ${colors.base02}; }
& > .needs-attention { border-color: ${colors.base09}; }
}
#pulseaudio {
&:hover { background: ${colors.base01}; }
&.muted {
background: ${colors.base08};
color: ${colors.base00};
&:hover {
color: ${colors.base08};
background: ${colors.base01};
}
}
}
#network {
&:hover { background: ${colors.base01}; }
&.disconnected {
color: ${colors.base00};
background: ${colors.base08};
}
}
2026-07-08 19:18:37 +03:00
#system,
#bat {
& .drawer-child > * { margin-right: 4px }
2026-04-07 22:40:16 +03:00
}
#keyboard-state label.locked {
2026-03-13 00:06:32 +03:00
background-color: ${colors.base00};
color: ${colors.base08};
}
2026-04-07 22:40:16 +03:00
#battery {
2026-06-08 03:24:54 +03:00
&.charging { color: ${accent}; }
2026-04-07 22:40:16 +03:00
&:not(.charging) {
&.warning {
color: ${colors.base00};
background-color: ${colors.base09};
}
&.critical {
background-color: ${colors.base08};
color: ${colors.base00};
animation-name: blink;
animation-duration: 0.5s;
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-direction: alternate;
}
}
&.full {
color: ${colors.base00};
2026-06-08 03:24:54 +03:00
background: ${accent};
2026-04-07 22:40:16 +03:00
}
2026-07-08 19:18:37 +03:00
&.plugged {
color: ${colors.base00};
background: ${colors.base0D};
}
2026-04-07 22:40:16 +03:00
}
@keyframes blink {
to {
background-color: ${colors.base00};
color: ${colors.base08};
}
}
'';
cssFile = pkgs.runCommand "waybar.css" {
nativeBuildInputs = [ pkgs.dart-sass ];
} "sass ${scssFile} $out";
in builtins.readFile cssFile;
};
2026-03-13 00:06:32 +03:00
2026-09-05 19:45:18 +03:00
wayland.windowManager.hyprland.settings.layer_rule = [
{
match.namespace = "waybar";
blur = true;
}
2026-03-13 00:06:32 +03:00
];
2026-04-07 22:40:16 +03:00
}