nix-dotfiles/home/services/polybar.nix

304 lines
8.2 KiB
Nix
Raw Permalink Normal View History

2024-10-05 12:10:18 +02:00
{ pkgs, lib, config, machineVars, ... }: let
colors = config.colors.defaultColorSet;
in {
services.polybar = {
enable = true;
script = ''
polybar top &
'';
package = pkgs.polybar.override {
githubSupport = true;
mpdSupport = true;
2024-10-05 12:10:18 +02:00
pulseSupport = true;
};
settings = {
2024-10-05 12:10:18 +02:00
"module/tray" = {
type = "internal/tray";
# padding = 4;
tray-spacing = "8px";
tray-maxsize = "25px";
# tray-background = colors.background;
};
"bar/top" = {
bottom = false;
# monitor =
2024-10-05 12:10:18 +02:00
# tray.position = "right";
background = colors.background;
foreground = colors.foreground;
padding = {
left = 2;
right = 2;
};
width = "100%";
height = 40;
fixed-center = true;
font = map (f: f + ":pixelsize=12:antialias=true:hinting=true") [
"Fira Code Retina"
"Noto Sans CJK JP"
"FiraCode Nerd Font"
];
modules = {
left = "xmonad";
center = "date";
right = builtins.concatStringsSep " " [
2024-10-05 12:10:18 +02:00
"filesystem"
(lib.optionalString (machineVars.wlanInterface != null) "wlan")
(lib.optionalString (machineVars.battery != null) "batt")
"pulseaudio"
"mpd"
2024-10-05 12:10:18 +02:00
"tray"
];
};
2024-10-05 12:10:18 +02:00
# tray = {
# padding = 4;
# maxsize = 25;
# background = colors.background;
# };
};
"module/xmonad" = {
type = "custom/script";
exec = "${pkgs.xmonad-log}/bin/xmonad-log";
tail = "true";
};
"module/date" = {
type = "internal/date";
interval = 1.0;
format-padding = 1;
label = "%date% | %time%";
label-padding = 1;
date = "W%W | %Y.%m.%d | %A";
time = "%R";
};
"module/wlan" = {
type = "internal/network";
interval = 1.0;
unknown-as-up = true;
# Wireless interfaces often start with `wl` and ethernet interface with `eno` or `eth`. Check " ifconfig/iwconfig "
interface = pkgs.lib.mkIf (machineVars.wlanInterface != null) machineVars.wlanInterface;
format = {
connected = "<label-connected>";
connected-padding = 1;
# connected-suffix = "%{A1:networkmanager_dmenu &:}%{A}"
# connected-suffix-padding = 1
# connected-suffix-foreground = ${colors.fg-alt}
# connected-suffix-background = ${colors.accent}
disconnected = "<label-disconnected>";
disconnected-padding = 1;
# disconnected-suffix = "%{A1:networkmanager_dmenu &:}%{A}"
# disconnected-suffix-padding = 1
# disconnected-suffix-foreground = ${colors.fg-alt}
# disconnected-suffix-background = ${colors.accent}
label = {
connected = "%essid%";
connected-padding = 1;
# connected-background = ${colors.fg-alt}
disconnected = "OFF";
disconnected-padding = 1;
# disconnected-background = ${colors.fg-alt}
};
};
};
"module/batt" = {
type = "internal/battery";
full-at = 99;
battery = pkgs.lib.mkIf (machineVars.battery != null) machineVars.battery;
adapter = "AC";
poll.interval = 5;
# format-charging = "<label-charging>"
format.charging.padding = 1;
# format-charging-suffix = "%{A1:xfce4-power-manager-settings &:}%{A}"
# format-charging-suffix-padding = 1
# format-charging-suffix-foreground = ${colors.fg-alt}
# format-charging-suffix-background = ${colors.accent}
#
# format-discharging = "<label-discharging>"
# format-discharging-padding = 1
#
# format-discharging-suffix = "%{A1:xfce4-power-manager-settings &:}%{A}"
# format-discharging-suffix-padding = 1
# format-discharging-suffix-foreground = ${colors.fg-alt}
# format-discharging-suffix-background = ${colors.accent}
#
label-charging = "%percentage%%";
label-discharging = "%percentage%%";
label-full = "FULL";
label = {
charging = {
padding = 1;
foreground = colors.green;
# background = ${colors.fg-alt}
};
discharging = {
padding = 1;
foreground = colors.yellow;
};
full = {
padding = 1;
foreground = colors.blue;
};
};
};
2024-10-05 12:10:18 +02:00
"module/pulseaudio" = {
type = "internal/pulseaudio";
# format-volume = "<bar-volume>}"
# format-volume = "%{A1:bash -c '~/.scripts/get-volume' &:}<bar-volume>%{A}"
# format-volume = <label-volume> <bar-volume>
# format-volume-padding = 1
# format-muted-padding = 1
2024-10-05 12:10:18 +02:00
format-volume = " <label-volume> <bar-volume>";
# label-volume = 
label-volume-foreground = colors.magenta;
# format-muted-foreground = "${colors.foreground-alt}";
label-muted = "mute";
bar.volume = {
width = 8;
foreground = [
"#55aa55"
"#55aa55"
"#55aa55"
"#55aa55"
"#55aa55"
"#f5a70a"
"#ff5555"
];
gradient = false;
indicator = "|";
# indicator-font = 1
fill = "";
# fill-font = 1
empty = "";
# empty-font = 1
# empty-foreground = "${colors.foreground-alt}";
};
#
# format-volume-prefix = "%{A3:pavucontrol &:}%{A}"
# format-volume-prefix-padding = 1
# format-volume-prefix-background = ${colors.fg-alt}
#
#
# format-muted-prefix = "%{A3:pavucontrol &:}%{A}"
# format-muted-prefix-padding = 1
# format-muted-prefix-background = ${colors.fg-alt}
#
# label-muted = " "
# label-muted-background = ${colors.fg-alt}
#
# bar-volume-width = 5
# bar-volume-indicator = ""
# bar-volume-empty = ""
# bar-volume-fill = ""
#
# bar-volume-indicator-foreground = ${colors.fg}
# bar-volume-indicator-background = ${colors.fg-alt}
#
# bar-volume-empty-foreground = ${colors.fg-alt}
# bar-volume-empty-background = ${colors.fg-alt}
#
# bar-volume-fill-foreground = ${colors.accent-alt}
# bar-volume-fill-background = ${colors.fg-alt}
};
"module/mpd" = {
type = "internal/mpd";
# your port and host here
host = "127.0.0.1";
port = "6600";
format-online = "<toggle> <label-song>";
# These are opposite, because polybar expects you to click the icon to change state,
# instead of showing the current state.
icon-pause = "";
icon.pause = {
font = 3;
padding = 1;
foreground = colors.green;
} ;
icon-play = "";
icon.play = {
font = 3;
padding = 1;
foreground = colors.red;
} ;
label-song = "%title%";
label.song = {
maxlen = 30;
ellipsis = true;
padding = 1;
};
};
"module/filesystem" = {
type = "internal/fs";
# Mountpoints to display
mount = [
"/"
];
# ] ++ (builtins.values machineVars.dataDrives.drives);
format.mount = [
{ background = "#101010"; }
];
# Seconds to sleep between updates
# Default: 30
interval = 10;
# Display fixed precision values
# Default: false
fixed-values = true;
2024-10-05 12:10:18 +02:00
# Margin (number of spaces, pixels, or points) to add before/after each module
# Individual side values can be defined using:
# module-margin-{left,right}
module-margin = "16px";
# spacing = "16px";
# Default: 90
# New in version 3.6.0
warn-percentage = 75;
};
"settings" = {
screenchange-reload = true;
};
};
};
}