Skip to content

Commit 1201618

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

File tree

1 file changed

+57
-24
lines changed

1 file changed

+57
-24
lines changed

modules/i3status-rust/hm.nix

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

0 commit comments

Comments
 (0)