diff --git a/homes/x86_64-linux/marley@nyx/default.nix b/homes/x86_64-linux/marley@nyx/default.nix index 333c3cc..2330399 100644 --- a/homes/x86_64-linux/marley@nyx/default.nix +++ b/homes/x86_64-linux/marley@nyx/default.nix @@ -9,6 +9,7 @@ in { home.keyboard.options = [ "apple:alupckeys" ]; + # FIXME: Remove once we are on NixOS targets.genericLinux = enabled; # FIXME: Remove this once nvim is set up @@ -53,6 +54,7 @@ in neo = enabled; rbw = enabled; ripgrep = enabled; + # TODO: is this xorg only? bundle under xorg if so rofi = enabled; ssh = enabled; starship = enabled; @@ -65,8 +67,10 @@ in }; services = { clipboard = enabled; - # TODO: bundle this with the WM under xorg + # TODO: bundle this under xorg dunst = enabled; + # TODO: bundle this with xorg + polybar = enabled; syncthing = enabled; }; xorg = { diff --git a/modules/home/services/polybar/default.nix b/modules/home/services/polybar/default.nix new file mode 100644 index 0000000..14f0271 --- /dev/null +++ b/modules/home/services/polybar/default.nix @@ -0,0 +1,398 @@ +{ + lib, + config, + pkgs, + ... +}: +let + inherit (lib) mkEnableOption mkIf; + + cfg = config.marleyos.services.polybar; + hasXorg = config.xsession.enable; +in +{ + options.marleyos.services.polybar.enable = mkEnableOption "polybar"; + + config = mkIf (cfg.enable && hasXorg) { + home.packages = with pkgs; [ + xorg.xrandr + ]; + + services.polybar = { + enable = true; + + script = # bash + '' + if type "xrandr" &/dev/null; then + for m in $(xrandr --query | grep " connected" | cut -d" " -f1); do + bar="main" + + if [[ "$m" == "DP-0" ]]; then + bar="tray" + fi + + MONITOR="$m" polybar -q "$bar" & + done + else + polybar -q main & + fi + ''; + + # colorblock theme from + # https://github.com/adi1090x/polybar-themes + settings = + let + color = rec { + background = "#26232f"; + foreground = background; + foreground-alt = "#c8c8cb"; + alpha = "#00000000"; + shade1 = "#d6adb5"; + shade2 = "#d7bdc3"; + dark = "#0a0a0a"; + }; + + fmt = { + prefix.font = 2; + padding = 2; + }; + pref = { + font = 2; + padding = 2; + }; + + hasRofi = config.marleyos.programs.rofi.enable; + cfgHome = config.xdg.configHome; + in + { + ### Global Settings ### + "settings" = { + screenchange.reload = true; + compositing = { + background = "source"; + foreground = "over"; + overline = "over"; + underline = "over"; + border = "over"; + }; + pseudo.transparency = false; + }; + "global/wm" = { + margin.bottom = 0; + }; + + ### Bars ### + "bar/main" = { + monitor.text = "\${env:MONITOR:}"; + monitor.strict = false; + override.redirect = true; + bottom = false; + fixed.center = true; + width = "99%"; + height = 40; + offset.x = "0.5%"; + offset.y = "1%"; + background = color.alpha; + inherit (color) foreground; + radius.top = 0.0; + radius.bottom = 0.0; + underline.size = 2; + underline.color = color.foreground; + border.size = 0; + border.color = color.background; + padding = 0; + module.margin.left = 0; + module.margin.right = 0; + font = + let + mkFt = s: "Maple Mono NF:pixelsize=${toString s};4"; + in + [ + (mkFt 10) + (mkFt 15) + ]; + modules.left = "launcher sep workspaces sep title sep mpd"; + modules.right = "filesystem sep cpu memory pulseaudio network date sep sysmenu"; + dim.value = 1.0; + wm.restack = "i3"; + enable.ipc = true; + scroll.up = "i3-msg workspace next_on_output"; + scroll.down = "i3-msg workspace prev_on_output"; + }; + + "bar/tray" = { + "inherit" = "bar/main"; + modules.right = "color-switch tray sep updates sep cpu memory pulseaudio network date sep sysmenu"; + }; + + ### Modules ### + "module/sep" = { + type = "custom/text"; + format = " "; + content.background = color.alpha; + content-foreground = color.alpha; + }; + + "module/launcher" = { + type = "custom/text"; + content = { + text = ""; + inherit (color) background; + foreground = color.shade2; + padding = 2; + }; + click.left = mkIf hasRofi "${cfgHome}/rofi/launchers/type-1/launcher.sh &"; + click.right = mkIf hasRofi "${cfgHome}/rofi/applets/bin/screenshot.sh &"; + }; + + "module/workspaces" = { + type = "internal/xworkspaces"; + pin.workspaces = true; + enable.click = true; + enable.scroll = true; + icon.text = [ + "1;1" + "2;2" + "3;3" + "4;4" + "5;5" + ]; + icon.default = 0; + format = { + text = ""; + inherit (color) background; + inherit (color) foreground; + }; + label = { + monitor = "%name%"; + active = { + text = "%icon%"; + background = color.shade2; + foreground = color.dark; + padding = 2; + }; + occupied = { + text = "%icon%"; + inherit (color) background; + foreground = color.shade2; + padding = 2; + }; + urgent = { + text = "%icon%"; + inherit (color) background; + foreground = "#cc6666"; + padding = 2; + }; + empty = { + text = "%icon%"; + inherit (color) background; + foreground = color.foreground-alt; + padding = 2; + }; + }; + }; + + "module/title" = { + type = "internal/xwindow"; + format.text = "