aboutsummaryrefslogtreecommitdiff
path: root/home-manager/homeModules/waybar.nix
blob: eb9cd41a70c54cccfddbf05a148073ae6c5b23e2 (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
{
  pkgs,
  lib,
  config,
  ...
}:
with lib; let
  cfg = config.waybar;
in {
  options = {
    waybar = {
      enable = mkEnableOption "enable waybar";
      windowManager = mkOption {
        description = "WM string to use with /workspaces and /language";
        default = "hyprland";
        type = types.str;
      };
      workspaceIcons = mkOption {
        default = {
          "1" = "α";
          "2" = "β";
          "3" = "γ";
          "4" = "δ";
          "5" = "ε";
          urgent = "λ";
          default = "ω";
        };
      };
    };
  };

  config = mkIf cfg.enable {
    programs.waybar = {
      enable = true;
      systemd.enable = true;
      style = with config.lib.stylix.colors.withHashtag;
        ''
          @define-color base00 ${base00}; @define-color base01 ${base01}; @define-color base02 ${base02}; @define-color base03 ${base03};
          @define-color base04 ${base04}; @define-color base05 ${base05}; @define-color base06 ${base06}; @define-color base07 ${base07};

          @define-color base08 ${base08}; @define-color base09 ${base09}; @define-color base0A ${base0A}; @define-color base0B ${base0B};
          @define-color base0C ${base0C}; @define-color base0D ${base0D}; @define-color base0E ${base0E}; @define-color base0F ${base0F};
        ''
        + builtins.readFile ./attachments/waybar-style.css;
      settings = {
        bar = {
          layer = "top";
          height = 30;
          spacing = 8;
          margin-down = 5;
          modules-left = ["${cfg.windowManager}/workspaces"];
          modules-center = ["clock"];
          modules-right = ["network" "custom/vpn" "memory" "temperature" "backlight" "pulseaudio" "${cfg.windowManager}/language" "tray" "battery"];
          "${cfg.windowManager}/workspaces" = {
            format = "{icon}";
            "format-icons" = cfg.workspaceIcons;
          };
          "${cfg.windowManager}/language" = {
            format = "{} <span font-family='Material Design Icons' rise='-1000' size='medium'>󰌌</span>";
            format-ru = "ru";
            format-en = "en";
          };
          "tray" = {
            spacing = 10;
          };
          "clock" = {
            format = "{:%H:%M  󰅐}";
            tooltip-format = "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>";
            format-alt = "{:%d %h %Y  󰃮}";
          };
          "memory" = {
            format = "{}% ";
          };
          "temperature" = {
            format = "{temperatureC}°C󰔏";
          };
          "backlight" = {
            format = "{percent}% {icon}";
            format-icons = ["󰃞" "󰃟" "󰃠"];
          };
          "battery" = {
            "states" = {
              good = 95;
              warning = 30;
              critical = 15;
            };
            format = "{capacity}% {icon}";
            format-charging = "{capacity}% 󰂄";
            format-plugged = "{capacity}% ";
            format-alt = "{icon}";
            format-icons = ["󱃍" "󰁼" "󰁼" "󰁽" "󰁾" "󰁿" "󰂀" "󰂁" "󰂂" "󰁹"];
          };
          "network" = {
            interface = "wlp*";
            format-wifi = "{essid} ({signalStrength}%) 󰤨";
            format-ethernet = "{ipaddr}/{cidr} 󰈀";
            tooltip-format = "{ifname} via {gwaddr} 󰩟";
            format-linked = "{ifname} (No IP) 󰩟";
            format-disconnected = "󰤫";
          };
          "custom/vpn" = {
            format = "{text}";
            exec = "${./attachments/hypr-scripts/toggle-vpn.sh} waybar";
            return-type = "json";
          };
          "pulseaudio" = {
            format = "{volume}% {icon}  {format_source}";
            format-bluetooth = "{volume}% <span font-family='Material Design Icons' rise='-2000' font-size='x-large'>󰥰</span>  {format_source}";
            format-bluetooth-muted = "󰟎 {format_source}";
            format-muted = "󰝟 {format_source}";
            format-source = "{volume}%󰍬";
            format-source-muted = "󰍭";

            "format-icons" = {
              headphone = "󰋋";
              hands-free = "";
              headset = "";
              phone = "";
              portable = "";
              car = "";
              muted-icon = "󰝟";
              default = ["󰕿" "󰖀" "󰕾"];
            };
          };
        };
      };
    };
  };
}