dotfiles/modules/nixos/graphical/polybar.nix

210 lines
7.6 KiB
Nix
Raw Normal View History

{ config, pkgs, lib, ... }: {
2022-04-30 21:27:42 +00:00
2022-12-21 21:18:03 +00:00
config = lib.mkIf (pkgs.stdenv.isLinux && config.services.xserver.enable) {
2022-04-30 21:27:42 +00:00
toggleBarCommand = "polybar-msg cmd toggle";
2022-05-15 03:31:04 +00:00
home-manager.users.${config.user} = {
2022-04-30 21:27:42 +00:00
services.polybar = {
enable = true;
2022-05-01 15:16:58 +00:00
package = pkgs.polybar.override {
pulseSupport = true;
githubSupport = true;
2023-01-22 00:46:56 +00:00
i3Support = true;
2022-05-01 15:16:58 +00:00
};
2022-04-30 21:27:42 +00:00
script = "polybar &";
config = {
2022-04-30 21:40:24 +00:00
"bar/main" = {
2022-05-01 15:16:58 +00:00
bottom = false;
2022-04-30 21:27:42 +00:00
width = "100%";
2022-05-01 15:16:58 +00:00
height = "22pt";
radius = 0;
# offset-y = -5;
2022-05-01 15:16:58 +00:00
# offset-y = "5%";
2022-04-30 21:27:42 +00:00
# dpi = 96;
background = config.theme.colors.base01;
foreground = config.theme.colors.base05;
2022-04-30 21:27:42 +00:00
line-size = "3pt";
2022-05-01 15:16:58 +00:00
border-top-size = 0;
border-right-size = 0;
border-left-size = 0;
border-bottom-size = "4pt";
border-color = config.theme.colors.base00;
2022-05-01 15:16:58 +00:00
padding-left = 2;
padding-right = 2;
2022-04-30 21:27:42 +00:00
module-margin = 1;
2022-05-08 19:30:05 +00:00
modules-left = "i3";
2022-05-01 15:16:58 +00:00
modules-center = "xwindow";
modules-right = "mailcount pulseaudio date power";
2022-04-30 21:27:42 +00:00
cursor-click = "pointer";
cursor-scroll = "ns-resize";
enable-ipc = true;
2022-05-01 15:16:58 +00:00
tray-position = "right";
# wm-restack = "generic";
# wm-restack = "bspwm";
# wm-restack = "i3";
# override-redirect = true;
2022-04-30 21:27:42 +00:00
};
2022-05-08 19:30:05 +00:00
"module/i3" = let padding = 2;
in {
type = "internal/i3";
pin-workspaces = false;
show-urgent = true;
strip-wsnumbers = true;
index-sort = true;
enable-click = true;
wrapping-scroll = true;
fuzzy-match = true;
format = "<label-state> <label-mode>";
label-focused = "%name%";
label-focused-foreground = config.theme.colors.base01;
label-focused-background = config.theme.colors.base05;
label-focused-underline = config.theme.colors.base03;
2022-05-08 19:30:05 +00:00
label-focused-padding = padding;
label-unfocused = "%name%";
label-unfocused-padding = padding;
label-visible = "%name%";
label-visible-underline = config.theme.colors.base01;
2022-05-08 19:30:05 +00:00
label-visible-padding = padding;
label-urgent = "%name%";
label-urgent-foreground = config.theme.colors.base00;
label-urgent-background = config.theme.colors.base08;
label-urgent-underline = config.theme.colors.base0F;
2022-05-08 19:30:05 +00:00
label-urgent-padding = padding;
};
2022-04-30 21:27:42 +00:00
"module/xworkspaces" = {
type = "internal/xworkspaces";
label-active = "%name%";
label-active-background = config.theme.colors.base05;
label-active-foreground = config.theme.colors.base01;
label-active-underline = config.theme.colors.base03;
2022-04-30 21:27:42 +00:00
label-active-padding = 1;
label-occupied = "%name%";
label-occupied-padding = 1;
label-urgent = "%name%";
label-urgent-background = config.theme.colors.base08;
2022-04-30 21:27:42 +00:00
label-urgent-padding = 1;
label-empty = "%name%";
label-empty-foreground = config.theme.colors.base06;
2022-04-30 21:27:42 +00:00
label-empty-padding = 1;
};
"module/xwindow" = {
type = "internal/xwindow";
label = "%title:0:60:...%";
};
2022-04-30 21:40:24 +00:00
# "module/filesystem" = {
# type = "internal/fs";
# interval = 25;
# mount-0 = "/";
# label-mounted = "%{F#F0C674}%mountpoint%%{F-} %percentage_used%%";
# label-unmounted = "%mountpoint% not mounted";
# label-unmounted-foreground = colors.disabled;
# };
"module/mailcount" = {
type = "custom/script";
interval = 10;
format = "<label>";
exec = builtins.toString (pkgs.writeShellScript "mailcount.sh" ''
2023-04-04 12:32:01 +00:00
${pkgs.notmuch}/bin/notmuch new > /dev/null
UNREAD=$(${pkgs.notmuch}/bin/notmuch count is:inbox and is:unread)
if [ $UNREAD = "0" ]; then
echo "%{T3}%{T-} "
else
echo "%{T2}%{T-} $UNREAD "
fi
'');
click-left =
"i3-msg 'exec --no-startup-id kitty --class aerc aerc'; sleep 0.15; i3-msg '[class=aerc] focus'";
};
2022-04-30 21:27:42 +00:00
"module/pulseaudio" = {
type = "internal/pulseaudio";
2022-05-01 16:10:38 +00:00
# format-volume-prefix = "VOL ";
# format-volume-prefix-foreground = colors.primary;
2022-05-01 15:16:58 +00:00
format-volume = "<ramp-volume> <label-volume>";
2022-05-02 03:16:03 +00:00
# format-volume-background = colors.background;
# label-volume-background = colors.background;
format-volume-foreground = config.theme.colors.base0B;
2022-04-30 21:27:42 +00:00
label-volume = "%percentage%%";
2022-05-01 16:10:38 +00:00
label-muted = " ---";
label-muted-foreground = config.theme.colors.base03;
2022-05-01 15:16:58 +00:00
ramp-volume-0 = "";
2022-05-01 16:10:38 +00:00
ramp-volume-1 = "";
2022-05-01 15:16:58 +00:00
ramp-volume-2 = "";
click-right = config.audioSwitchCommand;
2022-04-30 21:27:42 +00:00
};
2022-04-30 21:40:24 +00:00
# "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;
# format-prefix = "RAM ";
# format-prefix-foreground = colors.primary;
# label = "%percentage_used:2%%";
# };
# "module/cpu" = {
# type = "internal/cpu";
# interval = 2;
# format-prefix = "CPU ";
# format-prefix-foreground = colors.primary;
# label = "%percentage:2%%";
# };
# "network-base" = {
# type = "internal/network";
# interval = 5;
# format-connected = "<label-connected>";
# format-disconnected = "<label-disconnected>";
# label-disconnected = "%{F#F0C674}%ifname%%{F#707880} disconnected";
# };
# "module/wlan" = {
# "inherit" = "network-base";
# interface-type = "wireless";
# label-connected = "%{F#F0C674}%ifname%%{F-} %essid% %local_ip%";
# };
# "module/eth" = {
# "inherit" = "network-base";
# interface-type = "wired";
# label-connected = "%{F#F0C674}%ifname%%{F-} %local_ip%";
# };
2022-04-30 21:27:42 +00:00
"module/date" = {
type = "internal/date";
interval = 1;
2023-04-02 22:46:22 +00:00
date = "%d %b %l:%M %p";
2022-04-30 21:27:42 +00:00
date-alt = "%Y-%m-%d %H:%M:%S";
2022-05-04 00:32:47 +00:00
label = "%date%";
label-foreground = config.theme.colors.base0A;
2022-05-02 03:16:03 +00:00
# format-background = colors.background;
2022-04-30 21:27:42 +00:00
};
"module/power" = {
type = "custom/text";
content = " ";
click-left = config.powerCommand;
content-foreground = config.theme.colors.base04;
};
2022-04-30 21:27:42 +00:00
"settings" = {
screenchange-reload = true;
2022-05-01 15:16:58 +00:00
pseudo-transparency = false;
2022-04-30 21:27:42 +00:00
};
};
};
xsession.windowManager.i3.config.startup = [{
command = "pkill polybar; polybar -r main";
2022-04-30 21:27:42 +00:00
always = true;
notification = false;
}];
};
};
}