fix(home): Various polybar fixes

This commit is contained in:
punkfairie 2024-11-22 22:09:36 -08:00
parent ec923b007f
commit 0b5219c89f
Signed by: punkfairie
GPG key ID: A509E8F77FB9D696

View file

@ -5,38 +5,33 @@
... ...
}: }:
let let
inherit (lib) mkEnableOption mkIf; inherit (lib) mkEnableOption mkIf getExe;
cfg = config.marleyos.services.polybar; cfg = config.marleyos.services.polybar;
hasXorg = config.xsession.enable; hasXorg = config.xsession.enable;
xrandr = getExe pkgs.xorg.xrandr;
grep = getExe pkgs.gnugrep;
cut = "${pkgs.coreutils}/bin/cut";
in in
{ {
options.marleyos.services.polybar.enable = mkEnableOption "polybar"; options.marleyos.services.polybar.enable = mkEnableOption "polybar";
config = mkIf (cfg.enable && hasXorg) { config = mkIf (cfg.enable && hasXorg) {
home.packages = with pkgs; [
xorg.xrandr
];
services.polybar = { services.polybar = {
enable = true; enable = true;
package = config.lib.nixGL.wrap pkgs.polybar; package = config.lib.nixGL.wrap pkgs.polybar;
script = # bash script = # bash
'' ''
if type "xrandr" &/dev/null; then for m in $(${xrandr} --query | ${grep} " connected" | ${cut} -d" " -f1); do
for m in $(xrandr --query | grep " connected" | cut -d" " -f1); do bar="main"
bar="main"
if [[ "$m" == "DP-0" ]]; then if [[ "$m" == "DP-0" ]]; then
bar="tray" bar="tray"
fi fi
MONITOR="$m" polybar -q "$bar" & MONITOR="$m" polybar -q "$bar" &
done done
else
polybar -q main &
fi
''; '';
# colorblock theme from # colorblock theme from
@ -66,7 +61,7 @@ in
cfgHome = config.xdg.configHome; cfgHome = config.xdg.configHome;
in in
{ {
### Global Settings ### # Global Settings - - - - - - - - - - - - - - - - - - - - - - - - - -
"settings" = { "settings" = {
screenchange.reload = true; screenchange.reload = true;
compositing = { compositing = {
@ -82,7 +77,7 @@ in
margin.bottom = 0; margin.bottom = 0;
}; };
### Bars ### # Bars - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"bar/main" = { "bar/main" = {
monitor.text = "\${env:MONITOR:}"; monitor.text = "\${env:MONITOR:}";
monitor.strict = false; monitor.strict = false;
@ -123,10 +118,10 @@ in
"bar/tray" = { "bar/tray" = {
"inherit" = "bar/main"; "inherit" = "bar/main";
modules.right = "color-switch tray sep updates sep cpu memory pulseaudio network date sep sysmenu"; modules.right = "tray filesystem sep cpu memory pulseaudio network date sep sysmenu";
}; };
### Modules ### # Modules - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"module/sep" = { "module/sep" = {
type = "custom/text"; type = "custom/text";
format = " "; format = " ";
@ -343,6 +338,14 @@ in
background = color.shade2; background = color.shade2;
}; };
}; };
ramp.volume = {
text = [
""
""
""
];
font = 2;
};
}; };
"module/network" = { "module/network" = {
@ -393,6 +396,19 @@ in
}; };
click.left = mkIf hasRofi "${cfgHome}/rofi/powermenu/type-1/powermenu.sh &"; click.left = mkIf hasRofi "${cfgHome}/rofi/powermenu/type-1/powermenu.sh &";
}; };
"module/tray" = {
type = "internal/tray";
tray = {
size = 16;
background = color.shade2;
spacing = "5px";
};
format = {
background = color.shade2;
padding = 2;
};
};
}; };
}; };
}; };