summaryrefslogtreecommitdiff
path: root/lib/polybar.nix
blob: d3d5c3dd406c51c78bf3c49c845bc0710bb8afb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# https://github.com/0x746866/dots/blob/master/polybar/config
{ pkgs, lib, ... }:
let
  inherit (import ./const.nix) fontSize homedir;
  inherit (import ./theme.nix { inherit pkgs lib; })
    colors theme;

  size-int = fontSize + 3;
  size = toString size-int;
  bar-height = size-int + 16;

  bar-common = {
    background = colors."${theme}".background;
    foreground = colors."${theme}".foreground;

    font-0 = "Fira Code:size=${size};2";
    font-1 = "Font Awesome 5 Free:style=Solid:pixelsize=${size};2";
    font-2 = "Noto Color Emoji:scale=10;2";

    line-size = "2pt";
    border-size = "0pt";

    height = "${toString bar-height}pt";
    width = "100%";
    radius = 0;
    padding-left = 1;
    padding-right = 1;
    module-margin = 1;

    enable-ipc = true;
  };

in {
  services.polybar = {
    config = {
      # Top bar: user-level work stuff (workspaces, date, tray)
      "bar/top" = bar-common // {
        modules-left = [ "ewmh" ];
        modules-center = [ "date" ];
        modules-right = [ "pulseaudio" "battery" ];
        tray-position = "right";
        tray-background = colors."${theme}".background;
        tray-padding = 4;
        separator = " ";
        separator-foreground = colors.${theme}.highlight;
      };

      # Bottom bar: memory, temp, network (stacked above CPU bar)
      "bar/bottom" = bar-common // {
        bottom = true;
        offset-y = "${toString bar-height}pt";
        modules-left = [ "mem" ];
        modules-center = [ "temp" ];
        modules-right = [ "network-speed" ];
        separator = " │ ";
        separator-foreground = colors.${theme}.highlight;
      };

      # CPU bar: very bottom, just CPU cores
      "bar/cpu" = bar-common // {
        bottom = true;
        modules-center = [ "cpu" ];
      };

      "module/ewmh" = {
        type = "internal/xworkspaces";
        pin-workspaces = false;
        enable-click = true;
        enable-scroll = true;
        label-active = "%name%";
        label-active-foreground = colors.${theme}.background;
        label-active-background = colors.${theme}.cursor;
        label-active-padding = 1;
        label-occupied = "%name%";
        label-occupied-foreground = colors.${theme}.foreground;
        label-occupied-padding = 1;
        label-urgent = "%name%";
        label-urgent-foreground = colors.${theme}.background;
        label-urgent-background = colors.${theme}.red;
        label-urgent-padding = 1;
        label-empty = "%name%";
        label-empty-foreground = colors.${theme}.cyan;
        label-empty-padding = 1;
      };

      "module/date" = {
        type = "internal/date";
        interval = 5;
        date = "%a %Y.%m.%d";
        time = "%H:%M";
        label = "%date%  %time%";
        label-foreground = colors.${theme}.foreground;
      };

      "module/pulseaudio" = {
        type = "internal/pulseaudio";
        use-ui-max = false;
        interval = 5;
        format-volume = "<ramp-volume> <label-volume>";
        label-volume = "%percentage%%";
        label-muted = "🔇 muted";
        label-muted-foreground = colors.${theme}.cyan;
        ramp-volume-0 = "🔈";
        ramp-volume-1 = "🔉";
        ramp-volume-2 = "🔊";
        click-right = "pwvucontrol &";
      };

      "module/battery" = {
        type = "internal/battery";
        battery = "BAT0";
        adapter = "AC";
        full-at = 99;
        format-charging = "⚡ <label-charging>";
        format-discharging = "🔋 <label-discharging>";
        format-full = "✓ <label-full>";
        label-charging = "%percentage%%";
        label-discharging = "%percentage%%";
        label-full = "%percentage%%";
      };

      "module/cpu" = {
        type = "internal/cpu";
        interval = 2;
        format-padding = 1;
        format = "<label> <ramp-coreload>";
        label = "CPU %percentage:2%%";
        label-foreground = colors.${theme}.blue;
        ramp-coreload-0 = "▁";
        ramp-coreload-1 = "▂";
        ramp-coreload-2 = "▃";
        ramp-coreload-3 = "▄";
        ramp-coreload-4 = "▅";
        ramp-coreload-5 = "▆";
        ramp-coreload-6 = "▇";
        ramp-coreload-7 = "█";
        ramp-coreload-0-foreground = colors.${theme}.green;
        ramp-coreload-1-foreground = colors.${theme}.green;
        ramp-coreload-2-foreground = colors.${theme}.foreground;
        ramp-coreload-3-foreground = colors.${theme}.foreground;
        ramp-coreload-4-foreground = colors.${theme}.yellow;
        ramp-coreload-5-foreground = colors.${theme}.yellow;
        ramp-coreload-6-foreground = colors.${theme}.red;
        ramp-coreload-7-foreground = colors.${theme}.red;
      };

      "module/mem" = {
        type = "internal/memory";
        interval = 3;
        format = "<label> <bar-used>";
        label = "RAM %percentage_used%%";
        label-foreground = colors.${theme}.magenta;
        bar-used-width = 20;
        bar-used-foreground-0 = colors.${theme}.green;
        bar-used-foreground-1 = colors.${theme}.green;
        bar-used-foreground-2 = colors.${theme}.yellow;
        bar-used-foreground-3 = colors.${theme}.red;
        bar-used-indicator = "│";
        bar-used-indicator-foreground = colors.${theme}.foreground;
        bar-used-fill = "━";
        bar-used-empty = "━";
        bar-used-empty-foreground = colors.${theme}.highlight;
      };

      "module/temp" = {
        type = "internal/temperature";
        interval = 3;
        thermal-zone = 0;
        warn-temperature = 70;
        format = "<ramp> <label>";
        format-padding = 1;
        label = "%temperature-c%";
        ramp-0 = "❄";
        ramp-1 = "🌡";
        ramp-2 = "🔥";
        ramp-0-foreground = colors.${theme}.cyan;
        ramp-1-foreground = colors.${theme}.foreground;
        ramp-2-foreground = colors.${theme}.red;
        format-warn = "<label-warn>";
        label-warn = "🔥 %temperature-c%";
        label-warn-foreground = colors.${theme}.red;
      };

      "module/network-speed" = {
        type = "internal/network";
        interface-type = "wired";
        interval = 2;
        format-connected = "<label-connected>";
        label-connected = "↓ %downspeed:8% ↑ %upspeed:8%";
        label-connected-foreground = colors.${theme}.cyan;
        format-disconnected = "";
      };

    };
  };
}