Skip to content

Commit 40eaa81

Browse files
committed
i3status-rust: use mkTarget
1 parent 683d626 commit 40eaa81

File tree

1 file changed

+69
-25
lines changed

1 file changed

+69
-25
lines changed

modules/i3status-rust/hm.nix

Lines changed: 69 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,72 @@
1-
{ lib, config, ... }:
1+
{ mkTarget, lib, ... }:
22
let
3-
opacityHex = lib.toHexString (
4-
builtins.ceil (config.stylix.opacity.desktop * 255)
5-
);
3+
bar =
4+
{ cfg, colors }:
5+
lib.mapAttrs (n: v: if lib.hasSuffix "_bg" n then v + cfg.bgOpacity else v) (
6+
with colors.withHashtag;
7+
{
8+
idle_bg = base00;
9+
idle_fg = base05;
10+
info_bg = base09;
11+
info_fg = base00;
12+
good_bg = base01;
13+
good_fg = base05;
14+
warning_bg = base0A;
15+
warning_fg = base00;
16+
critical_bg = base08;
17+
critical_fg = base00;
18+
separator_bg = base00;
19+
separator_fg = base05;
20+
}
21+
);
622
in
7-
{
8-
# Merge this with your bar's theme's overrides with //config.lib.stylix.i3status-rust.bar
9-
config.lib.stylix.i3status-rust.bar =
10-
lib.mapAttrs (n: v: if lib.hasSuffix "_bg" n then v + opacityHex else v)
11-
(
12-
with config.lib.stylix.colors.withHashtag;
13-
{
14-
idle_bg = base00;
15-
idle_fg = base05;
16-
info_bg = base09;
17-
info_fg = base00;
18-
good_bg = base01;
19-
good_fg = base05;
20-
warning_bg = base0A;
21-
warning_fg = base00;
22-
critical_bg = base08;
23-
critical_fg = base00;
24-
separator_bg = base00;
25-
separator_fg = base05;
26-
}
27-
);
23+
mkTarget {
24+
name = "i3status-rust";
25+
humanName = "i3status-rust";
26+
27+
extraOptions = {
28+
barNames = lib.mkOption {
29+
type = with lib.types; listOf str;
30+
default = [ ];
31+
description = "i3status-rust bars to apply theming to.";
32+
example = [ "default" ];
33+
};
34+
bgOpacity = lib.mkOption {
35+
type = lib.types.singleLineStr;
36+
default = "FF";
37+
internal = true;
38+
};
39+
};
40+
41+
imports = lib.singleton (
42+
{ config, ... }:
43+
{
44+
lib.stylix.i3status-rust.bar =
45+
lib.warn
46+
"stylix: `config.lib.stylix.i3status-rust.bar` has been replace with `config.stylix.targets.i3status-rust.barNames` and will be removed after 26.11."
47+
(bar {
48+
cfg = config.stylix.targets.i3status-rust;
49+
inherit (config.lib.stylix) colors;
50+
});
51+
}
52+
);
53+
54+
configElements = [
55+
(
56+
{ opacity }:
57+
{
58+
stylix.targets.i3status-rust.bgOpacity = lib.toHexString (
59+
builtins.ceil (opacity.desktop * 255)
60+
);
61+
}
62+
)
63+
(
64+
{ cfg, colors }:
65+
{
66+
programs.i3status-rust.bars = lib.genAttrs cfg.barNames (
67+
_: bar { inherit cfg colors; }
68+
);
69+
}
70+
)
71+
];
2872
}

0 commit comments

Comments
 (0)