summaryrefslogtreecommitdiffhomepage
path: root/nix/default.nix
blob: aea52edf8c87694ae7ef227abeaeda7b942bdf17 (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
{
  config,
  lib,
  pkgs,
  ...
}:
with lib;
let
  cfg = config.programs.nixmobar;
in
{
  options.programs.nixmobar = {
    enable = mkEnableOption (mdDoc "Xmobar, a minimalistic status bar");

    font = mkOption {
      type = types.str;
      default = "Fira Code 13";
      description = mdDoc "Main font for Xmobar.";
    };

    additionalFonts = mkOption {
      type = types.listOf types.str;
      default = [ "Fira Code 22" ];
      description = mdDoc "Additional fonts for use in Xmobar.";
    };

    bgColor = mkOption {
      type = types.str;
      default = "#282a36";
      description = mdDoc "Background color of Xmobar.";
    };

    fgColor = mkOption {
      type = types.str;
      default = "#f8f8f2";
      description = mdDoc "Foreground (text) color of Xmobar.";
    };

    textOffset = mkOption {
      type = types.int;
      default = 2;
      description = mdDoc "Offset of the text from the edge.";
    };

    verbose = mkOption {
      type = types.bool;
      default = true;
      description = mdDoc "Enable verbose mode for Xmobar.";
    };

    allDesktops = mkOption {
      type = types.bool;
      default = true;
      description = mdDoc "Show Xmobar on all desktops.";
    };

    lowerOnStart = mkOption {
      type = types.bool;
      default = true;
      description = mdDoc "Whether Xmobar should be lowered on start.";
    };

    overrideRedirect = mkOption {
      type = types.bool;
      default = true;
      description = mdDoc "If true, Xmobar will bypass window manager redirection.";
    };

    position = mkOption {
      type = types.str;
      default = "BottomH 26";
      description = mdDoc "Position of Xmobar on the screen.";
    };

    alpha = mkOption {
      type = types.int;
      default = 200;
      description = mdDoc "Transparency level of Xmobar (0-255).";
    };

    commands = mkOption {
      type = types.lines;
      default = ''
        Run XMonadLog
        Run DiskU ["/", "<fc=#bd93f9><fn=1>\\xf0a0</fn></fc> <free>"] [] 50
        Run DiskIO ["/", "<read><fc=#bd93f9> R</fc> <fc=#bd93f9>W</fc> <write>"] ["-t", "", "-w", "4"] 10
        Run Date "%a %_d %b %H:%M:%S" "date" 10
        # Add more commands here, one per line
      '';
      description = mdDoc "List of commands to run in Xmobar, each on a new line.";
    };

    alignSep = mkOption {
      type = types.str;
      default = "}{";
      description = mdDoc "Separators for alignment left and right.";
    };

    template = mkOption {
      type = types.str;
      default = "<hspace=8/>%XMonadLog% }{ %load%|%disku%|%diskio%|<fc=#bd93f9><fn=1></fn></fc>%wifi_signal%|%dynnetwork%|<fc=#bd93f9><fn=1>󰈐</fn></fc>%cat0%|%multicoretemp%|%cpufreq%|%multicpu%|<fc=#bd93f9><fn=1></fn></fc>%kbd%|%memory% %swap%|%battery%|%alsa:default:Master%|<fc=#bd93f9><fn=1></fn></fc>%kernel_version%|%date%|%_XMONAD_TRAYPAD%";
      description = mdDoc "Template string for Xmobar layout.";
    };
  };

  config = mkIf cfg.enable {
    home.packages = [ pkgs.xmobar ];
    xdg.configFile."xmobar/.xmobarrc" = {
      text = # haskell
        ''
          Config {
            font = "${cfg.font}",
            additionalFonts = [${lib.concatMapStringsSep ", " (s: "\"" + s + "\"") cfg.additionalFonts}],
            bgColor = "${cfg.bgColor}",
            fgColor = "${cfg.fgColor}",
            textOffset = ${toString cfg.textOffset},
            verbose = ${if cfg.verbose then "True" else "False"},
            allDesktops = ${if cfg.allDesktops then "True" else "False"},
            lowerOnStart = ${if cfg.lowerOnStart then "True" else "False"},
            overrideRedirect = ${if cfg.overrideRedirect then "True" else "False"},
            position = ${cfg.position},
            alpha = ${toString cfg.alpha},
            commands = [${cfg.commands}],
            alignSep = "${cfg.alignSep}",
            template = "${cfg.template}"
          }
        '';
    };
  };
}