idiosyn/home/config/nil/bar.nix

341 lines
8.5 KiB
Nix
Raw Normal View History

2024-08-25 19:10:52 +02:00
{ ... }: { config, lib, pkgs, ... }@args:
let
osConfig = args.osConfig or { };
brightnessctl = lib.getExe pkgs.brightnessctl;
2024-08-25 19:10:52 +02:00
busctl = osConfig.systemd.package + /bin/busctl;
gammarelay = lib.getExe pkgs.wl-gammarelay-rs;
pwvucontrol = lib.getExe pkgs.pwvucontrol;
2024-08-27 10:14:09 +02:00
rfkill = pkgs.util-linux + /bin/rfkill;
2024-08-25 19:10:52 +02:00
wpctl = osConfig.services.pipewire.wireplumber.package + /bin/wpctl;
2024-08-27 10:14:09 +02:00
wttrbar = pkgs.wttrbar + /bin/wttrbar;
2024-08-25 19:10:52 +02:00
gr = cmd: "${busctl} --user -- ${cmd} rs.wl-gammarelay / rs.wl.gammarelay";
gr-set = gr "set-property";
gr-call = gr "call";
in lib.mkIf (osConfig.hardware.graphics.enable or false) {
programs.waybar = {
enable = true;
2024-08-26 21:58:18 +02:00
systemd.enable = true;
2024-08-25 19:10:52 +02:00
package = pkgs.waybar.override {
cavaSupport = false;
hyprlandSupport = false;
jackSupport = false;
mpdSupport = false;
sndioSupport = false;
};
2024-08-26 19:45:44 +02:00
style = pkgs.writeText "waybar-style.css"
(with config.lib.stylix.colors.withHashtag; ''
* {
font: 600 12pt sans-serif;
}
window, tooltip {
background: ${base00};
color: ${base05};
}
tooltip {
border-color: ${base0D};
}
2024-09-04 22:33:02 +02:00
#tray, #taskbar, .modules-center, .modules-right {
2024-08-27 10:14:09 +02:00
padding: 0 3mm;
2024-08-26 19:45:44 +02:00
}
2024-09-04 22:33:02 +02:00
#tray image {
2024-08-31 10:23:55 +02:00
padding: 0 1.5mm;
}
2024-09-04 22:33:02 +02:00
#taskbar button {
padding: 0 1.5mm;
}
.modules-right label.module {
padding: 1.5mm 3mm;
min-width: 5mm;
}
#battery.warning {
color: ${yellow};
2024-08-26 19:45:44 +02:00
}
#battery.critical {
color: ${red};
2024-08-26 19:45:44 +02:00
}
#temperature.critical {
color: ${red};
}
#idle_inhibitor.activated {
color: ${yellow};
}
2024-08-31 00:32:24 +02:00
#pulseaudio.sink.muted {
color: ${base03};
}
#pulseaudio.source {
color: ${yellow};
}
#pulseaudio.source.source-muted {
2024-08-26 19:45:44 +02:00
color: ${base03};
}
'') |> lib.mkForce;
2024-08-25 19:10:52 +02:00
settings = {
main = {
layer = "top";
position = "bottom";
2024-08-27 10:14:09 +02:00
spacing = 0;
2024-08-25 19:10:52 +02:00
2024-09-04 22:33:02 +02:00
modules-left = [
"tray"
"wlr/taskbar"
];
2024-08-27 10:14:09 +02:00
modules-center = [ "mpris" ];
2024-09-04 22:33:02 +02:00
2024-08-25 19:10:52 +02:00
modules-right = [
2024-08-27 10:14:09 +02:00
"idle_inhibitor"
"network"
2024-08-25 19:10:52 +02:00
"bluetooth"
2024-08-27 10:14:09 +02:00
"temperature"
2024-08-25 19:10:52 +02:00
"cpu"
"memory"
"disk"
"backlight"
"custom/gammarelay"
2024-08-25 19:10:52 +02:00
"pulseaudio#sink"
"pulseaudio#source"
2024-08-27 10:14:09 +02:00
"battery"
"custom/weather"
2024-08-25 19:10:52 +02:00
"clock"
];
2024-08-31 10:23:55 +02:00
tray.spacing = 0;
2024-09-04 22:33:02 +02:00
"wlr/taskbar" = {
format = "{icon}";
icon-size = 16;
tooltip-format = "{title}";
on-click = "activate";
on-click-right = "close";
};
2024-08-27 10:14:09 +02:00
mpris = {
interval = 1;
format = "{status_icon}{dynamic}{player_icon}";
dynamic-order = [ "title" "artist" "position" "length" ];
dynamic-separator = "";
ellipsis = "";
player-icons = {
default = "";
mopidy = "";
mpv = "";
};
status-icons = {
playing = "";
paused = "";
stopped = "";
};
};
idle_inhibitor = {
format = "{icon}";
format-icons = {
activated = "󱎴";
deactivated = "󰷛";
};
timeout = 15.0;
2024-08-25 19:10:52 +02:00
};
2024-08-27 15:48:18 +02:00
network = {
2024-08-27 10:14:09 +02:00
interval = 10;
format = "{icon}󰅀 {bandwidthDownBytes}󰅃 {bandwidthUpBytes}";
format-icons = {
disconnected = "󰌙";
linked = "󰌚";
ethernet = "󰌘";
wifi = [ "󰤯" "󰤟" "󰤢" "󰤢" "󰤨" ];
};
tooltip-format = "{ifname}";
tooltip-format-wifi = "{essid} ({signalStrength}%)";
2024-08-25 19:10:52 +02:00
};
bluetooth = {
2024-08-27 10:14:09 +02:00
format = "";
format-off = "󰂲";
format-on = "󰂯";
format-connected = "󰂱";
format-connected-battery = "󰥈 {device_battery_percentage}%";
on-click-right = "${rfkill} toggle bluetooth";
2024-08-25 19:10:52 +02:00
tooltip-format-connected-battery = "{device_enumerate}";
tooltip-format-enumerate-connected-battery = "{device_alias}\t{device_battery_percentage}%";
};
cpu = {
format = " {usage}%";
};
memory = {
2024-08-27 10:14:09 +02:00
format = " {percentage}% {swapPercentage}%";
tooltip-format = "{used:0.1f}/{total:0.1f}GiB\n{swapUsed:0.1f}/{swapTotal:0.1f}GiB";
2024-08-26 19:45:44 +02:00
states = {
warning = 96;
critical = 99;
};
2024-08-25 19:10:52 +02:00
};
temperature = let
fmt = "{temperatureC}°C";
in {
format = "󰔏 ${fmt}";
format-critical = "󰸁 ${fmt}";
tooltip-format = fmt;
};
disk = {
format = " {percentage_used}%";
path = "/home";
tooltip-format = "{used}/{total}";
};
2024-08-27 10:14:09 +02:00
"backlight" = let
fmt = "{percent}%";
in {
format = "{icon} ${fmt}";
format-icons = [ "󰛩" "󱩎" "󱩐" "󱩐" "󱩑" "󱩒" "󱩓" "󱩔" "󱩕" "󱩖" "󰛨" ];
2024-08-25 19:10:52 +02:00
2024-08-27 10:14:09 +02:00
on-click = "${brightnessctl} set 100%";
on-click-right = "${brightnessctl} set 5%";
on-scroll-up = "${brightnessctl} set +1%";
on-scroll-down = "${brightnessctl} set 1%-";
2024-08-27 10:14:09 +02:00
tooltip-format = fmt;
};
2024-08-27 10:14:09 +02:00
"custom/gammarelay" = let
fmt = "{}K";
in {
format = "󰖦 ${fmt}";
2024-08-25 19:10:52 +02:00
exec = "${gammarelay} watch {t}";
2024-08-27 10:14:09 +02:00
on-click = "${gr-set} Temperature q 6500";
on-click-right = "${gr-set} Temperature q 4500";
2024-08-25 19:10:52 +02:00
on-scroll-up = "${gr-call} UpdateTemperature n +100";
on-scroll-down = "${gr-call} UpdateTemperature n -100";
2024-08-27 10:14:09 +02:00
tooltip-format = fmt;
};
2024-08-25 19:10:52 +02:00
2024-08-27 10:14:09 +02:00
battery = {
states = {
warning = 25;
critical = 15;
};
2024-08-27 10:14:09 +02:00
format = "{icon} {capacity}%";
format-icons = {
full = "󰚥";
2024-08-27 10:14:09 +02:00
plugged = "󰚥";
charging = [ "󰢟" "󰢜" "󰂆" "󰂇" "󰂈" "󰢝" "󰂉" "󰢞" "󰂊" "󰂋" "󰂅" ];
discharging = [ "󱃍" "󰁺" "󰁻" "󰁼" "󰁽" "󰁿" "󰁿" "󰂀" "󰂁" "󰂂" "󰁹" ];
2024-08-25 19:10:52 +02:00
};
format-time = "{H}:{M}";
weighted-average = true;
};
"pulseaudio#sink" = let
fmt = "{volume}%";
in {
format = "{icon} ${fmt}";
format-bluetooth = "󰂰 ${fmt}";
2024-08-31 00:32:24 +02:00
format-muted = "󰖁 ${fmt}";
2024-08-25 19:10:52 +02:00
format-icons = {
headphone = "";
2024-08-31 00:32:24 +02:00
default = [ "󰕿" "󰖀" "󰕾" ];
2024-08-25 19:10:52 +02:00
};
2024-08-31 00:32:24 +02:00
on-click = "${wpctl} set-mute @DEFAULT_AUDIO_SINK@ toggle";
on-click-right = pwvucontrol;
2024-08-25 19:10:52 +02:00
on-scroll-up = "${wpctl} set-volume @DEFAULT_AUDIO_SINK@ 1%+";
on-scroll-down = "${wpctl} set-volume @DEFAULT_AUDIO_SINK@ 1%-";
2024-08-31 00:32:24 +02:00
max-volume = 100;
2024-08-25 19:10:52 +02:00
};
"pulseaudio#source" = let
fmt = "{volume}%";
in {
format = "{format_source}";
format-source = "󰍬 ${fmt}";
format-source-muted = "󰍭 ${fmt}";
2024-08-31 00:32:24 +02:00
on-click = "${wpctl} set-mute @DEFAULT_AUDIO_SOURCE@ toggle";
on-click-right = pwvucontrol;
2024-08-25 19:10:52 +02:00
on-scroll-up = "${wpctl} set-volume @DEFAULT_AUDIO_SOURCE@ 1%+";
on-scroll-down = "${wpctl} set-volume @DEFAULT_AUDIO_SOURCE@ 1%-";
};
2024-08-27 10:14:09 +02:00
"custom/weather" = {
exec = "${wttrbar} --hide-conditions --custom-indicator '{ICON} {temp_C}°C'";
return-type = "json";
interval = 900;
};
2024-08-25 19:10:52 +02:00
clock = {
2024-08-27 10:14:09 +02:00
interval = 1;
format = "{:%H:%M:%S %Z}";
format-alt = "󰃭{:%Y-%m-%d}";
2024-08-25 19:10:52 +02:00
tooltip-format = "<tt><small>{calendar}</small></tt>";
calendar = {
mode = "month";
weeks-pos = "left";
on-scroll = 1;
format = {
weeks = "{:%W}";
};
};
2024-08-27 10:14:09 +02:00
actions = {
on-scroll-up = "shift_up";
on-scroll-down = "shift_down";
};
2024-08-25 19:10:52 +02:00
};
};
};
};
systemd.user.services = {
waybar = {
Unit = {
After = [ "graphical-session.target" ];
};
};
};
2024-08-25 19:10:52 +02:00
systemd.user.targets = {
tray = {
Unit = {
2024-08-26 21:58:18 +02:00
BindsTo = [ "waybar.service" ];
After = [ "waybar.service" ];
2024-08-25 19:10:52 +02:00
};
};
};
}