From 13dc2f983e5d3cb45bbc3fd0da340e6bb3060f1e Mon Sep 17 00:00:00 2001 From: Jacob Bachmann Date: Sat, 3 Aug 2024 20:05:49 +0200 Subject: [PATCH] feat: add polybar --- users/gandalf/modules/gui/i3/default.nix | 10 ++ users/gandalf/modules/gui/i3/polybar.nix | 176 +++++++++++++++++++++++ 2 files changed, 186 insertions(+) create mode 100644 users/gandalf/modules/gui/i3/polybar.nix diff --git a/users/gandalf/modules/gui/i3/default.nix b/users/gandalf/modules/gui/i3/default.nix index f058244..b19506c 100644 --- a/users/gandalf/modules/gui/i3/default.nix +++ b/users/gandalf/modules/gui/i3/default.nix @@ -5,17 +5,25 @@ let # common = (import ../common.nix) { pkgs = pkgs; lib = lib; }; common = (import ../common.nix) { inherit pkgs; inherit lib; }; + start-polybar = pkgs.writeShellScript "start-polybar" '' + ${pkgs.polybarFull}/bin/polybar-msg cmd quit + echo "---" | tee -a /tmp/polybar.log + ${pkgs.polybarFull}/bin/polybar 2>&1 | tee -a /tmp/polybar.log & disown + ''; + in { imports = [ ./autorandr.nix + ./polybar.nix ./rofi.nix ]; home.packages = with pkgs; [ alacritty dmenu + xclip # tool to access the x clipboard from a console application wireplumber feh # lightweight image viewer (also sets wallpaper) brightnessctl # control screen brightness @@ -34,9 +42,11 @@ in enable = true; config = { modifier = "Mod4"; + bars = [ ]; terminal = "${pkgs.alacritty}/bin/alacritty"; menu = "${config.programs.rofi.package}/bin/rofi -show drun"; startup = with pkgs; [ + { command = "${start-polybar}"; } { command = "${gnome.gnome-keyring}/bin/gnome-keyring-daemon --start --components=ssh,secrets,pkcs11"; } { command = "${autorandr}/bin/autorandr -c"; } { command = "${feh}/bin/feh --bg-fill ${common.wallpaper.default}"; } diff --git a/users/gandalf/modules/gui/i3/polybar.nix b/users/gandalf/modules/gui/i3/polybar.nix new file mode 100644 index 0000000..b6ed38c --- /dev/null +++ b/users/gandalf/modules/gui/i3/polybar.nix @@ -0,0 +1,176 @@ +{ pkgs, ... }: { + home.packages = with pkgs; [ + polybarFull + ]; + xdg.configFile."polybar/config.ini" = { + text = '' + [colors] + background = #FFFFFF + background-alt = #D3D3D3 + foreground = #000000 + primary = #F0C674 + secondary = #8ABEB7 + blue = #4276b9 + alert = #A54242 + disabled = #707880 + + [bar/main] + width = 100% + height = 24pt + radius = 10 + + background = ''${colors.background} + foreground = ''${colors.foreground} + + line-size = 3pt + + border-size = 4pt + border-color = #00000000 + + padding-left = 0 + padding-right = 1 + + module-margin = 1 + + separator =  + separator-foreground = ''${colors.disabled} + + font-0 = DejaVuSansM Nerd Font:pixelsize=12;3 + + modules-left = xworkspaces xwindow + modules-right = systray wlan eth pulseaudio filesystem cpu temperature memory date + + cursor-click = pointer + cursor-scroll = ns-resize + + enable-ipc = true + + [module/systray] + type = internal/tray + + format-margin = 8pt + tray-spacing = 4pt + tray-size = 55% + + tray-background = ''${colors.blue} + format-background = ''${colors.blue} + format-padding = 10px + + format-radius = 5.0 + + [module/xworkspaces] + type = internal/xworkspaces + + label-active = %name% + label-active-background = ''${colors.background-alt} + label-active-padding = 1 + + label-occupied = %name% + label-occupied-padding = 1 + + label-urgent = %name% + label-urgent-background = ''${colors.alert} + label-urgent-padding = 1 + + label-empty = %name% + label-empty-foreground = ''${colors.disabled} + label-empty-padding = 1 + + [module/xwindow] + type = internal/xwindow + label = %title:0:60:...% + + [module/filesystem] + type = internal/fs + interval = 25 + + mount-0 = /home + + label-mounted = %free% + format-mounted =  + + [module/pulseaudio] + type = internal/pulseaudio + + format-volume = + + label-volume = %percentage%% + label-muted = 󰖁 + ramp-volume-0 = 󰕿 + ramp-volume-1 = 󰖀 + ramp-volume-2 = 󰕾 + + click-right = pavucontrol + + [module/xkeyboard] + type = internal/xkeyboard + blacklist-0 = num lock + + label-layout = %layout% + label-layout-foreground = ''${colors.primary} + + label-indicator-padding = 2 + label-indicator-margin = 1 + label-indicator-foreground = ''${colors.background} + label-indicator-background = ''${colors.secondary} + + [module/memory] + type = internal/memory + interval = 2 + label = %gb_used:2% + format =