/ modules / home / programs / hyprland / waybar.nix
waybar.nix
  1  { pkgs
  2  , lib
  3  # , config
  4  , ...
  5  }:
  6  # let
  7  #   betterTransition = "all 0.3s cubic-bezier(.55,-0.68,.48,1.682)";
  8  # in
  9  # with lib; {
 10  #   programs.waybar = {
 11  #     enable = true;
 12  #     package = pkgs.waybar;
 13  #     settings = [
 14  #       {
 15  #         layer = "top";
 16  #         position = "top";
 17  #         modules-center = [ "hyprland/workspaces" ];
 18  #         modules-left = [
 19  #           "custom/startmenu"
 20  #           "hyprland/window"
 21  #           "pulseaudio"
 22  #           "cpu"
 23  #           "memory"
 24  #           "idle_inhibitor"
 25  #         ];
 26  #         modules-right = [
 27  #           "custom/hyprbindings"
 28  #           "custom/notification"
 29  #           "custom/exit"
 30  #           "battery"
 31  #           "tray"
 32  #           "clock"
 33  #         ];
 34  
 35  #         "hyprland/workspaces" = {
 36  #           format = "{name}";
 37  #           format-icons = {
 38  #             default = " ";
 39  #             active = " ";
 40  #             urgent = " ";
 41  #           };
 42  #           on-scroll-up = "hyprctl dispatch workspace e+1";
 43  #           on-scroll-down = "hyprctl dispatch workspace e-1";
 44  #         };
 45  #         "clock" = {
 46  #           format = " {:L%H:%M}";
 47  #           tooltip = true;
 48  #           tooltip-format = "<big>{:%A, %d.%B %Y }</big>\n<tt><small>{calendar}</small></tt>";
 49  #         };
 50  #         "hyprland/window" = {
 51  #           max-length = 22;
 52  #           separate-outputs = false;
 53  #           rewrite = {
 54  #             "" = " 🙈 No Windows? ";
 55  #           };
 56  #         };
 57  #         "memory" = {
 58  #           interval = 5;
 59  #           format = " {}%";
 60  #           tooltip = true;
 61  #         };
 62  #         "cpu" = {
 63  #           interval = 5;
 64  #           format = " {usage:2}%";
 65  #           tooltip = true;
 66  #         };
 67  #         "custom/gpu" = {
 68  #           format = "GPU: {}";
 69  #           return-type = "plain";
 70  #           interval = 2;
 71  #           exec = pkgs.writeShellScript "gpu-usage" ''
 72  #             cat /sys/class/drm/card0/device/gpu_busy_percent 2>/dev/null || echo "N/A"
 73  #           '';
 74  #         };
 75  #         "disk" = {
 76  #           format = " {free}";
 77  #           tooltip = true;
 78  #         };
 79  #         "network" = {
 80  #           format-icons = [
 81  #             "󰤯"
 82  #             "󰤟"
 83  #             "󰤢"
 84  #             "󰤥"
 85  #             "󰤨"
 86  #           ];
 87  #           format-ethernet = " {bandwidthDownOctets}";
 88  #           format-wifi = "{icon} {signalStrength}%";
 89  #           format-disconnected = "󰤮";
 90  #           tooltip = false;
 91  #         };
 92  #         "tray" = {
 93  #           spacing = 12;
 94  #         };
 95  #         "pulseaudio" = {
 96  #           format = "{icon} {volume}% {format_source}";
 97  #           format-bluetooth = "{volume}% {icon} {format_source}";
 98  #           format-bluetooth-muted = " {icon} {format_source}";
 99  #           format-muted = " {format_source}";
100  #           format-source = " {volume}%";
101  #           format-source-muted = "";
102  #           format-icons = {
103  #             headphone = "";
104  #             hands-free = "";
105  #             headset = "";
106  #             phone = "";
107  #             portable = "";
108  #             car = "";
109  #             default = [
110  #               ""
111  #               ""
112  #               ""
113  #             ];
114  #           };
115  #           on-click = "sleep 0.1 && pavucontrol";
116  #         };
117  #         "custom/exit" = {
118  #           tooltip = false;
119  #           format = "";
120  #           on-click = "sleep 0.1 && wlogout";
121  #         };
122  #         "custom/startmenu" = {
123  #           tooltip = false;
124  #           format = "";
125  #           on-click = "sleep 0.1 && rofi-launcher";
126  #         };
127  #         "custom/hyprbindings" = {
128  #           tooltip = false;
129  #           format = "󱕴";
130  #           on-click = "sleep 0.1 && list-keybinds";
131  #         };
132  #         "idle_inhibitor" = {
133  #           format = "{icon}";
134  #           format-icons = {
135  #             activated = "";
136  #             deactivated = "";
137  #           };
138  #           tooltip = "true";
139  #         };
140  #         "custom/notification" = {
141  #           tooltip = false;
142  #           format = "{icon} {}";
143  #           format-icons = {
144  #             notification = "<span foreground='red'><sup></sup></span>";
145  #             none = "";
146  #             dnd-notification = "<span foreground='red'><sup></sup></span>";
147  #             dnd-none = "";
148  #             inhibited-notification = "<span foreground='red'><sup></sup></span>";
149  #             inhibited-none = "";
150  #             dnd-inhibited-notification = "<span foreground='red'><sup></sup></span>";
151  #             dnd-inhibited-none = "";
152  #           };
153  #           return-type = "json";
154  #           exec-if = "which swaync-client";
155  #           exec = "swaync-client -swb";
156  #           on-click = "sleep 0.1 && task-waybar";
157  #           escape = true;
158  #         };
159  #         "battery" = {
160  #           states = {
161  #             warning = 30;
162  #             critical = 5;
163  #           };
164  #           format = "{icon} {capacity}%";
165  #           format-charging = "󰂄 {capacity}%";
166  #           format-plugged = "󱘖 {capacity}%";
167  #           format-icons = [
168  #             "󰁺"
169  #             "󰁻"
170  #             "󰁼"
171  #             "󰁽"
172  #             "󰁾"
173  #             "󰁿"
174  #             "󰂀"
175  #             "󰂁"
176  #             "󰂂"
177  #             "󰁹"
178  #           ];
179  #           tooltip = false;
180  #         };
181  #       }
182  #     ];
183  #     style = ''
184  #       * {
185  #         font-family: JetBrainsMono Nerd Font Mono;
186  #         font-size: 16px;
187  #         border-radius: 0px;
188  #         border: none;
189  #         min-height: 0px;
190  #       }
191  #       window#waybar {
192  #         background: rgba(0,0,0,0);
193  #       }
194  #       #workspaces {
195  #         color: #f0f0f0;
196  #         background: #333333;
197  #         margin: 4px 4px;
198  #         padding: 5px 5px;
199  #         border-radius: 16px;
200  #       }
201  #       #workspaces button {
202  #         font-weight: bold;
203  #         padding: 0px 5px;
204  #         margin: 0px 3px;
205  #         border-radius: 16px;
206  #         color: #f0f0f0;
207  #         background: linear-gradient(45deg, #ff5733, #ffbd33);
208  #         opacity: 0.5;
209  #         transition: ${betterTransition};
210  #       }
211  #       #workspaces button.active {
212  #         opacity: 1.0;
213  #       }
214  #       #workspaces button:hover {
215  #         opacity: 0.8;
216  #       }
217  #       tooltip {
218  #         background: #f0f0f0;
219  #         border: 1px solid #ff5733;
220  #         border-radius: 12px;
221  #       }
222  #       tooltip label {
223  #         color: #ff5733;
224  #       }
225  #       #window, #pulseaudio, #cpu, #memory, #idle_inhibitor {
226  #         font-weight: bold;
227  #         margin: 4px 0px;
228  #         margin-left: 7px;
229  #         padding: 0px 18px;
230  #         background: #333333;
231  #         color: #f0f0f0;
232  #         border-radius: 24px 10px 24px 10px;
233  #       }
234  #       #custom-startmenu {
235  #         color: #66cc66;
236  #         background: #444444;
237  #         font-size: 28px;
238  #         margin: 0px;
239  #         padding: 0px 30px 0px 5px;
240  #         border-radius: 0px 0px 40px 0px;
241  #       }
242  #       #custom-hyprbindings, #network, #battery,
243  #       #custom-notification, #tray, #custom-exit {
244  #         font-weight: bold;
245  #         background: #555555;
246  #         color: #f0f0f0;
247  #         margin: 4px 0px;
248  #         margin-right: 7px;
249  #         border-radius: 10px 24px 10px 24px;
250  #         padding: 0px 18px;
251  #       }
252  #       #clock {
253  #         font-weight: bold;
254  #         color: #0D0E5;
255  #         background: linear-gradient(90deg, #66cc66, #33cc33);
256  #         margin: 0px;
257  #         padding: 0px 5px 0px 30px;
258  #         border-radius: 0px 0px 0px 40px;
259  #       }
260  #     '';
261  #   };
262  # }
263  let
264    terminal = "kitty";
265    base00 = "1D2021";
266    base01 = "282828";
267    base03 = "504945";
268    base05 = "EBDBB2";
269    base06 = "FBF1C7";
270    base07 = "F2E5BC";
271    base08 = "FB4934";
272    base09 = "FE8019";
273    base0A = "FABD2F";
274    base0B = "B8BB26";
275    base0C = "8EC07C";
276    base0D = "83A598";
277    base0E = "D3869B";
278    base0F = "D65D0E";
279  in
280  with lib; {
281    programs.waybar = lib.mkIf pkgs.stdenv.isLinux {
282      enable = true;
283      systemd = {
284        enable = true;
285        enableDebug = false;
286        enableInspect = false;
287      };
288      settings = [
289        {
290          layer = "top";
291          position = "top";
292  
293          modules-left = [ "custom/startmenu" "tray" "hyprland/window" ];
294          modules-center = [ "hyprland/workspaces" ];
295          modules-right = [ "idle_inhibitor" "custom/notification" "pulseaudio" "battery" "clock" "custom/exit" ];
296  
297          "hyprland/workspaces" = {
298            format = "{name}";
299            format-icons = {
300              default = " ";
301              active = " ";
302              urgent = " ";
303            };
304            on-scroll-up = "hyprctl dispatch workspace e+1";
305            on-scroll-down = "hyprctl dispatch workspace e-1";
306          };
307          "clock" = {
308            format = '' {:%H:%M}'';
309            /*
310              ''{: %I:%M %p}'';
311              */
312            tooltip = true;
313            tooltip-format = "<big>{:%A, %d.%B %Y }</big><tt><small>{calendar}</small></tt>";
314          };
315          "hyprland/window" = {
316            max-length = 60;
317            separate-outputs = false;
318          };
319          "memory" = {
320            interval = 5;
321            format = " {}%";
322            tooltip = true;
323            on-click = "${terminal} -e btop";
324          };
325          "cpu" = {
326            interval = 5;
327            format = " {usage:2}%";
328            tooltip = true;
329            on-click = "${terminal} -e btop";
330          };
331          "disk" = {
332            format = " {free}";
333            tooltip = true;
334            # Not working with zaneyos window open then closes
335            #on-click = "${terminal} -e sh -c df -h ; read";
336          };
337          "network" = {
338            format-icons = [ "󰤯" "󰤟" "󰤢" "󰤥" "󰤨" ];
339            format-ethernet = " {bandwidthDownBits}";
340            format-wifi = " {bandwidthDownBits}";
341            format-disconnected = "󰤮";
342            tooltip = false;
343            on-click = "${terminal} -e btop";
344          };
345          "tray" = {
346            spacing = 12;
347          };
348          "pulseaudio" = {
349            format = "{icon} {volume}% {format_source}";
350            format-bluetooth = "{volume}% {icon} {format_source}";
351            format-bluetooth-muted = " {icon} {format_source}";
352            format-muted = " {format_source}";
353            format-source = " {volume}%";
354            format-source-muted = "";
355            format-icons = {
356              headphone = "";
357              hands-free = "";
358              headset = "";
359              phone = "";
360              portable = "";
361              car = "";
362              default = [ "" "" "" ];
363            };
364            on-click = "pavucontrol";
365          };
366          "custom/exit" = {
367            tooltip = false;
368            format = "⏻";
369            on-click = "sleep 0.1 && wlogout";
370          };
371          "custom/startmenu" = {
372            tooltip = false;
373            format = " ";
374            # exec = "rofi -show drun";
375            on-click = "rofi -show drun";
376          };
377          "idle_inhibitor" = {
378            format = "{icon}";
379            format-icons = {
380              activated = " ";
381              deactivated = " ";
382            };
383            tooltip = "true";
384          };
385          "custom/notification" = {
386            tooltip = false;
387            format = "{icon} {}";
388            format-icons = {
389              notification = "<span foreground='red'><sup></sup></span>";
390              none = "";
391              dnd-notification = "<span foreground='red'><sup></sup></span>";
392              dnd-none = "";
393              inhibited-notification = "<span foreground='red'><sup></sup></span>";
394              inhibited-none = "";
395              dnd-inhibited-notification = "<span foreground='red'><sup></sup></span>";
396              dnd-inhibited-none = "";
397            };
398            return-type = "json";
399            exec-if = "which swaync-client";
400            exec = "swaync-client -swb";
401            on-click = "swaync-client -t";
402            escape = true;
403          };
404          "battery" = {
405            states = {
406              warning = 30;
407              critical = 5;
408            };
409            format = "{icon} {capacity}%";
410            format-charging = "󰂄 {capacity}%";
411            format-plugged = "󱘖 {capacity}%";
412            format-icons = [ "󰁺" "󰁻" "󰁼" "󰁽" "󰁾" "󰁿" "󰂀" "󰂁" "󰂂" "󰁹" ];
413            on-click = "";
414            tooltip = false;
415          };
416        }
417      ];
418      style = concatStrings [
419        ''
420          * {
421            font-size: 12pt;
422            font-family: JetBrainsMono Nerd Font, Font Awesome, sans-serif;
423            font-weight: bold;
424          }
425          window#waybar {
426            /*
427              background-color: rgba(26,27,38,0);
428              border-bottom: 1px solid rgba(26,27,38,0);
429              border-radius: 0px;
430              color: #${base0F};
431            */
432  
433            background-color: rgba(26,27,38,0);
434            border-bottom: 1px solid rgba(26,27,38,0);
435            border-radius: 0px;
436            color: #${base0F};
437          }
438          #workspaces {
439            /*
440              Eternal
441              background: linear-gradient(180deg, #${base00}, #${base01});
442              margin: 5px 5px 5px 0px;
443              padding: 0px 10px;
444              border-radius: 0px 5px 5px 0px;
445              border: 0px;
446              font-style: normal;
447              color: #${base00};
448            */
449            background: linear-gradient(45deg, #${base01}, #${base01});
450            margin: 5px;
451            padding: 0px 1px;
452            border-radius: 5px;
453            border: 0px;
454            font-style: normal;
455            color: #${base00};
456          }
457          #workspaces button {
458            padding: 0px 5px;
459            margin: 4px 3px;
460            border-radius: 5px;
461            border: 0px;
462            color: #${base00};
463            background: linear-gradient(45deg, #${base0D}, #${base0E});
464            opacity: 0.5;
465            transition: all 0.3s ease-in-out;
466          }
467          #workspaces button.active {
468            padding: 0px 5px;
469            margin: 4px 3px;
470            border-radius: 5px;
471            border: 0px;
472            color: #${base00};
473            background: linear-gradient(45deg, #${base0D}, #${base0E});
474            opacity: 1.0;
475            min-width: 40px;
476            transition: all 0.3s ease-in-out;
477          }
478          #workspaces button:hover {
479            border-radius: 5px;
480            color: #${base00};
481            background: linear-gradient(45deg, #${base0D}, #${base0E});
482            opacity: 0.8;
483          }
484          tooltip {
485            background: #${base00};
486            border: 1px solid #${base0E};
487            border-radius: 5px;
488          }
489          tooltip label {
490            color: #${base07};
491          }
492          #window {
493            /*
494              Eternal
495              color: #${base05};
496              background: #${base00};
497              border-radius: 5px;
498              margin: 5px;
499              padding: 2px 20px;
500            */
501            margin: 5px;
502            padding: 2px 20px;
503            color: #${base05};
504            background: #${base01};
505            border-radius: 5px 5px 5px 5px;
506          }
507          #memory {
508            color: #${base0F};
509            /*
510              Eternal
511              background: #${base00};
512              border-radius: 5px 5px 5px 5px;
513              margin: 5px;
514              padding: 2px 20px;
515            */
516            background: #${base01};
517            margin: 5px;
518            padding: 2px 20px;
519            border-radius: 5px 5px 5px 5px;
520          }
521          #clock {
522            color: #${base0B};
523              background: #${base00};
524              border-radius: 5px 5px 5px 5px;
525              margin: 5px;
526              padding: 2px 20px;
527          }
528          #idle_inhibitor {
529            color: #${base0A};
530              background: #${base00};
531              border-radius: 5px 5px 5px 5px;
532              margin: 3px;
533              padding: 2px 20px;
534          }
535          #cpu {
536            color: #${base07};
537              background: #${base00};
538              border-radius: 5px 5px 5px 5px;
539              margin: 5px;
540              padding: 2px 20px;
541          }
542          #disk {
543            color: #${base0F};
544              background: #${base00};
545              border-radius: 5px 5px 5px 5px;
546              margin: 5px;
547              padding: 2px 20px;
548          }
549          #battery {
550            color: #${base08};
551            background: #${base00};
552            border-radius: 5px 5px 5px 5px;
553            margin: 5px;
554            padding: 2px 20px;
555          }
556          #network {
557            color: #${base09};
558            background: #${base00};
559            border-radius: 5px 5px 5px 5px;
560            margin: 5px;
561            padding: 2px 20px;
562          }
563          #tray {
564            color: #${base05};
565            background: #${base00};
566            border-radius: 5px 5px 5px 5px;
567            margin: 5px;
568            padding: 2px 5px;
569          }
570          #pulseaudio {
571            color: #${base0D};
572            /*
573              Eternal
574              background: #${base00};
575              border-radius: 5px 5px 5px 5px;
576              margin: 5px;
577              padding: 2px 20px;
578            */
579            background: #${base01};
580            margin: 4px;
581            padding: 2px 20px;
582            border-radius: 5px 5px 5px 5px;
583          }
584          #custom-notification {
585            color: #${base0C};
586            background: #${base00};
587            border-radius: 5px 5px 5px 5px;
588            margin: 5px;
589            padding: 2px 20px;
590          }
591          #custom-startmenu {
592            color: #${base0E};
593            background: #${base00};
594            border-radius: 0px 5px 5px 0px;
595            margin: 5px 5px 5px 0px;
596            padding: 2px 20px;
597          }
598          #idle_inhibitor {
599            color: #${base09};
600            background: #${base00};
601            border-radius: 5px 5px 5px 5px;
602            margin: 5px;
603            padding: 2px 20px;
604          }
605          #custom-exit {
606            color: #${base0E};
607            background: #${base00};
608            border-radius: 5px 0px 0px 5px;
609            margin: 5px 0px 5px 5px;
610            padding: 2px 20px;
611          }
612        ''
613      ];
614    };
615  }