home-manager/polybar.nix

322 lines
9.0 KiB
Nix

{ pkgs, home-manager, ... }: {
services.polybar = {
enable = true;
package = pkgs.polybar.override {
i3Support = true;
pulseSupport = true;
};
script = ''
PATH="$PATH:/run/current-system/sw/bin"
# Terminate already running bar instances
killall -q polybar
# Wait until the processes have been shut down
while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done
IFS=$'\n'
for m in $(xrandr --query | grep " connected"); do
if [[ $m = *primary* ]]; then
MONITOR=$(echo $m | cut -d" " -f1) polybar --reload bottom_main &
else
MONITOR=$(echo $m | cut -d" " -f1) polybar --reload bottom &
fi
done
'';
settings = {
"colors" = {
background = "#222";
background-alt = "#444";
foreground = "#dfdfdf";
foreground-alt = "#999";
primary = "#ffb52a";
secondary = "#e60053";
alert = "#bd2c40";
};
"bar/bottom" = {
monitor = "\${env:MONITOR:}";
bottom = true;
radius = 0;
height = 25;
width = "100%";
padding = 1;
line-size = 3;
module-margin = 1;
background = "\${colors.background}";
foreground = "\${colors.foreground}";
font = [
"fixed:pixelsize=14;1"
"unifont:fontformat=truetype:size=12:antialias=false;0"
"FontAwesome5Free-Solid:weight=heavy:size=12"
#"siji:pixelsize=14;1"
];
modules-left = "hostname bspwm i3";
modules-center = "mpd";
modules-right = "dirty root xbacklight volume wlan eth zram memory cpu battery date";
scroll-up = "i3wm-wsnext";
scroll-down = "i3wm-wsprev";
};
"bar/bottom_main" = {
monitor = "\${env:MONITOR:}";
bottom = true;
radius = 0;
height = 25;
width = "100%";
padding = 1;
line-size = 3;
module-margin = 1;
background = "\${colors.background}";
foreground = "\${colors.foreground}";
font = [
"fixed:pixelsize=14;1"
"unifont:fontformat=truetype:size=12:antialias=false;0"
"FontAwesome5Free-Solid:weight=heavy:size=12"
#"siji:pixelsize=14;1"
];
modules-left = "hostname bspwm i3";
modules-center = "mpd";
modules-right = "dirty root xbacklight volume wlan eth zram memory cpu battery date tray";
scroll-up = "i3wm-wsnext";
scroll-down = "i3wm-wsprev";
};
"module/tray" = {
type = "internal/tray";
};
"module/root" = {
type = "internal/fs";
interval = "10";
mount = [ "/" ];
format-mounted = "<label-mounted> <bar-used>";
format-mounted-underline = "#f876cd";
label-mounted = "%mountpoint%%{F-} %free% of %total%";
label-mounted-foreground = "\${colors.foreground-alt}";
bar-used-width = 10;
bar-used-fill = "";
bar-used-empty = "";
bar-used-indicator = "";
bar-used-empty-foreground = "#444444";
format-prefix = " ";
format-prefix-foreground = "\${colors.foreground-alt}";
};
"module/battery" = {
type = "internal/battery";
format-charging = "<animation-charging> <label-charging>";
format-charging-underline = "#ffb52a";
format-discharging = "<ramp-capacity> <label-discharging>";
format-discharging-underline = "#ffb52a";
format-full-prefix = " ";
format-full-prefix-foreground = "\${colors.foreground-alt}";
format-full-underline = "#ffb52a";
ramp-capacity = [" " " " " " " " " "];
animation-charging = [" " " " " " " " " "];
animation-charging-framerate = 750;
};
"module/hostname" = {
type = "custom/script";
exec = "echo $(uname -n)";
interval = 256;
format = "<label>";
format-underline = "#bdf1e1";
format-prefix = " ";
format-prefix-foreground = "\${colors.foreground-alt}";
};
"module/dirty" = {
type = "custom/script";
exec = "grep -e Dirty: /proc/meminfo | sed 's/Dirty: *//; s/ kB/000/' | numfmt --to=iec --suffix=B | sed 's/\\([0-9]\\)\\([A-Z]\\)/\\1 \\2/'";
interval = 1;
format = "<label> Dirty";
format-underline = "#7f4849";
format-prefix = " ";
format-prefix-foreground = "\${colors.foreground-alt}";
};
"module/cpu" = {
type = "internal/cpu";
interval = 1;
label = "%percentage%%";
format = "<label> <ramp-coreload>";
format-underline = "#f90000";
ramp-coreload-spacing = 0;
ramp-coreload = ["" "" "" "" "" "" "" ""];
format-prefix = " ";
format-prefix-foreground = "\${colors.foreground-alt}";
};
"module/memory" = {
type = "internal/memory";
interval = 2;
label = "%gb_used%/%gb_total%";
format = "<label> <bar-used>";
format-underline = "#4bffdc";
bar-used-width = 10;
bar-used-fill = "";
bar-used-empty = "";
bar-used-indicator = "";
bar-used-empty-foreground = "#444444";
format-prefix = " ";
format-prefix-foreground = "\${colors.foreground-alt}";
};
"module/zram" = {
type = "internal/memory";
interval = 2;
label = "%gb_swap_used%/%gb_swap_total%";
format = "<label> <bar-swap-used>";
format-underline = "#256d7b";
bar-swap-used-width = 10;
bar-swap-used-fill = "";
bar-swap-used-empty = "";
bar-swap-used-indicator = "";
bar-swap-used-empty-foreground = "#444444";
format-prefix = " ";
format-prefix-foreground = "\${colors.foreground-alt}";
};
"module/date" = {
type = "internal/date";
interval = 1;
date = "%Y-%m-%d";
time = "%H:%M:%S";
label = "%date% %time%";
format-underline = "#0a6cf5";
format-prefix = " ";
format-prefix-foreground = "\${colors.foreground-alt}";
};
"module/volume" = {
type = "internal/pulseaudio";
interval = 5;
label-volume = "%percentage%%";
format-volume = "<ramp-volume> <label-volume> <bar-volume>";
format-volume-underline = "#0000aa";
ramp-volume = ["" "" ""];
ramp-volume-foreground = "\${colors.foreground-alt}";
label-muted = "sound muted";
format-muted-prefix = " ";
format-muted-prefix-foreground = "\${colors.foreground-alt}";
bar-volume-width = 10;
bar-volume-fill = "";
bar-volume-empty = "";
bar-volume-indicator = "";
bar-volume-empty-foreground = "#444444";
use-ui-max = false;
click-right = "pavucontrol";
middle-click = "blueman-manager";
};
"module/i3" = {
type = "internal/i3";
pin-workspaces = true;
label-mode-padding = 2;
label-mode-foreground = "#000";
label-mode-background = "\${colors.primary}";
label-focused = "%name%";
label-focused-background = "\${colors.background-alt}";
label-focused-underline = "\${colors.primary}";
label-focused-padding = 2;
label-unfocused = "%name%";
label-unfocused-padding = 2;
label-visible = "%name%";
label-visible-background = "\${colors.background-alt}";
label-visible-underline = "\${colors.primary}";
label-visible-padding = 2;
label-urgent = "%name%";
label-urgent-background = "\${colors.alert}";
label-urgent-padding = 2;
wrapping-scroll = false;
};
"module/wlan" = {
type = "internal/network";
interface-type = "wireless";
interval = 3;
label-connected = "%ifname% %essid% (%local_ip%)";
format-connected = "<ramp-signal> <label-connected>";
format-connected-underline = "#9f78e1";
label-disconnected = "%ifname% disconnected";
format-disconnected = "<label-disconnected>";
label-disconnected-foreground = "\${colors.foreground-alt}";
format-disconnected-underline = "\${self.format-connected-underline}";
ramp-signal = ["" "" "" "" ""];
ramp-signal-foreground = "\${colors.foreground-alt}";
};
"module/eth" = {
type = "internal/network";
interface-type = "wired";
interval = 3;
label-connected = "%ifname% - %local_ip% (%linkspeed%)";
format-connected-prefix = " ";
format-connected-prefix-foreground = "\${colors.foreground-alt}";
label-disconnected = "%ifname% disconnected";
label-disconnected-foreground = "\${colors.foreground-alt}";
format-connected-underline = "#55aa55";
format-disconnected-underline = "\${self.format-connected-underline}";
};
# Backlight?
};
};
}