about summary refs log tree commit diff stats
path: root/modules/by-name/i3/i3status-rust/module.nix
blob: 5bd911d8b5e6553935e47f3a509522c9bdcb71c9 (plain) (blame)
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
{
  config,
  lib,
  pkgs,
  ...
}: let
  cfg = config.soispha.programs.i3status-rust;

  mkScript = name: deps:
    lib.getExe (pkgs.writeShellApplication {
      inherit name;
      text = builtins.readFile ./scripts/${name};

      inheritPath = false;
      runtimeInputs = deps;
    });
in {
  options.soispha.programs.i3status-rust = {
    enable = lib.mkEnableOption "i3status-rust";

    package = lib.mkPackageOption pkgs "i3status-rust-patched" {};
  };

  config = lib.mkIf cfg.enable {
    home-manager.users.soispha = {
      programs.i3status-rust = {
        enable = true;
        inherit (cfg) package;

        bars.default = {
          settings = {
            icons = {
              icons = "material-nf";

              overrides = {
                cpu = [
                  "󰍛" # nf-md-memory
                ];
                memory_mem = ""; # nf-fa-bars
              };
            };

            theme = {
              theme = "slick";

              overrides = {
                separator = "native";
                alternating_tint_bg = "none";
                alternating_tint_fg = "none";
              };
            };
          };

          blocks = [
            {
              block = "time";
              format = " $timestamp.datetime(format:'%d/%m/%y (%a) %H:%M %:z') ";
              interval = 60;
            }

            {
              # TODO(@bpeetz): Switch to “music” when mpd gets mpris support  <2025-05-20>
              block = "custom";
              interval = "once";
              persistent = true;
              command = mkScript "mpd_song_name.sh" [pkgs.mpc pkgs.coreutils];
              hide_when_empty = true;
              shell = "${lib.getExe pkgs.dash}";
              format = " $text.str(max_width:60,rot_interval:0.5) ";
            }

            {
              block = "sound";
              driver = "pulseaudio";
              headphones_indicator = true;
            }

            # System info
            {
              block = "cpu";
            }
            {
              block = "memory";
              format = " $icon $mem_used_percents {($swap_used_percents.eng(range:1..)) | }";
            }
            {
              block = "amd_gpu";
              format = "  $icon $utilization (^icon_memory_mem $vram_used_percents) ";
            }

            {
              block = "net";
              format = " ^icon_net_down $speed_down.eng(prefix:Ki) ^icon_net_up $speed_up.eng(prefix:Ki) ";
            }
            {
              block = "privacy";
              driver = [
                {name = "v4l";}
                {name = "pipewire";}
              ];
            }

            {
              block = "disk_space";
              path = "/srv";
              info_type = "used";
              format = " $icon $used.eng(prefix:Gi) ($percentage) ";
              backend = "btrfs";

              # warn if 80 % is used, alert after 90 % used.
              warning = 80;
              alert = 90;
            }
            {
              block = "backlight";
              missing_format = "";
            }
            {
              block = "battery";
              missing_format = "";
            }

            # {
            #   block = "calendar";
            #
            #   source = {
            #     calendars = ["user/calendar"];
            #     auth = {
            #       type = "unauthenticated";
            #     };
            #   };
            # }
            # {
            #   block = "focused_window";
            #   driver = "wlr_toplevel_management";
            # }
            # {
            #   block = "maildir";
            #   display_type = "new";
            #   inboxes = ["~/.local/share/maildir/soispha/*"];
            #   interval = 60;
            #   threshold_critical = 10;
            #   threshold_warning = 1;
            # }
          ];
        };
      };

      programs.i3bar-river.settings.command = "${lib.getExe cfg.package} config-default.toml";
    };
  };
}