2020-09-02 04:37:42 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.programs.i3status-rust;
|
|
|
|
|
2023-05-07 13:42:55 +02:00
|
|
|
settingsFormat = pkgs.formats.toml { };
|
2020-09-02 04:37:42 +02:00
|
|
|
|
|
|
|
in {
|
2023-03-16 12:48:55 +01:00
|
|
|
meta.maintainers = with lib.maintainers; [ farlion thiagokokada ];
|
2020-09-02 04:37:42 +02:00
|
|
|
|
|
|
|
options.programs.i3status-rust = {
|
2023-07-02 01:45:18 +02:00
|
|
|
enable = mkEnableOption "a replacement for i3-status written in Rust";
|
2020-09-02 04:37:42 +02:00
|
|
|
|
|
|
|
bars = mkOption {
|
|
|
|
type = types.attrsOf (types.submodule {
|
|
|
|
options = {
|
|
|
|
|
|
|
|
blocks = mkOption {
|
|
|
|
type = settingsFormat.type;
|
|
|
|
default = [
|
2023-03-16 12:48:55 +01:00
|
|
|
{ block = "cpu"; }
|
2020-09-02 04:37:42 +02:00
|
|
|
{
|
|
|
|
block = "disk_space";
|
|
|
|
path = "/";
|
|
|
|
info_type = "available";
|
2023-03-16 12:48:55 +01:00
|
|
|
interval = 20;
|
2020-09-02 04:37:42 +02:00
|
|
|
warning = 20.0;
|
|
|
|
alert = 10.0;
|
2023-03-16 12:48:55 +01:00
|
|
|
format = " $icon root: $available.eng(w:2) ";
|
2020-09-02 04:37:42 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
block = "memory";
|
2023-03-16 12:48:55 +01:00
|
|
|
format = " $icon $mem_total_used_percents.eng(w:2) ";
|
|
|
|
format_alt = " $icon_swap $swap_used_percents.eng(w:2) ";
|
2020-09-02 04:37:42 +02:00
|
|
|
}
|
|
|
|
{
|
2023-03-16 12:48:55 +01:00
|
|
|
block = "sound";
|
|
|
|
click = [{
|
|
|
|
button = "left";
|
|
|
|
cmd = "pavucontrol";
|
|
|
|
}];
|
2020-09-02 04:37:42 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
block = "time";
|
2023-03-16 12:48:55 +01:00
|
|
|
interval = 5;
|
|
|
|
format = " $timestamp.datetime(f:'%a %d/%m %R') ";
|
2020-09-02 04:37:42 +02:00
|
|
|
}
|
|
|
|
];
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2020-09-02 04:37:42 +02:00
|
|
|
Configuration blocks to add to i3status-rust
|
2023-07-01 01:30:13 +02:00
|
|
|
{file}`config`. See
|
|
|
|
<https://github.com/greshake/i3status-rust/blob/master/blocks.md>
|
2020-09-02 04:37:42 +02:00
|
|
|
for block options.
|
|
|
|
'';
|
2021-10-09 11:14:08 +02:00
|
|
|
example = literalExpression ''
|
2020-09-02 04:37:42 +02:00
|
|
|
[
|
|
|
|
{
|
|
|
|
block = "disk_space";
|
|
|
|
path = "/";
|
|
|
|
info_type = "available";
|
|
|
|
interval = 60;
|
|
|
|
warning = 20.0;
|
|
|
|
alert = 10.0;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
block = "sound";
|
2023-03-16 12:48:55 +01:00
|
|
|
format = " $icon $output_name {$volume.eng(w:2) |}";
|
|
|
|
click = [
|
|
|
|
{
|
|
|
|
button = "left";
|
|
|
|
cmd = "pavucontrol --tab=3";
|
|
|
|
}
|
|
|
|
];
|
2020-09-02 04:37:42 +02:00
|
|
|
mappings = {
|
2023-03-16 12:48:55 +01:00
|
|
|
"alsa_output.pci-0000_00_1f.3.analog-stereo" = "";
|
|
|
|
"bluez_sink.70_26_05_DA_27_A4.a2dp_sink" = "";
|
2020-09-02 04:37:42 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
settings = mkOption {
|
|
|
|
type = settingsFormat.type;
|
|
|
|
default = { };
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2020-09-02 04:37:42 +02:00
|
|
|
Any extra options to add to i3status-rust
|
2023-07-01 01:30:13 +02:00
|
|
|
{file}`config`.
|
2020-09-02 04:37:42 +02:00
|
|
|
'';
|
2021-10-09 11:14:08 +02:00
|
|
|
example = literalExpression ''
|
2020-09-02 04:37:42 +02:00
|
|
|
{
|
|
|
|
theme = {
|
2023-03-16 12:48:55 +01:00
|
|
|
theme = "solarized-dark";
|
2020-09-02 04:37:42 +02:00
|
|
|
overrides = {
|
|
|
|
idle_bg = "#123456";
|
|
|
|
idle_fg = "#abcdef";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
icons = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "none";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2020-09-02 04:37:42 +02:00
|
|
|
The icons set to use. See
|
2023-07-01 01:30:13 +02:00
|
|
|
<https://github.com/greshake/i3status-rust/blob/master/doc/themes.md>
|
2020-09-02 04:37:42 +02:00
|
|
|
for a list of available icon sets.
|
|
|
|
'';
|
2023-03-16 12:48:55 +01:00
|
|
|
example = "awesome6";
|
2020-09-02 04:37:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
theme = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "plain";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2020-09-02 04:37:42 +02:00
|
|
|
The theme to use. See
|
2023-07-01 01:30:13 +02:00
|
|
|
<https://github.com/greshake/i3status-rust/blob/master/doc/themes.md>
|
2020-09-02 04:37:42 +02:00
|
|
|
for a list of available themes.
|
|
|
|
'';
|
|
|
|
example = "gruvbox-dark";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
default = {
|
|
|
|
default = {
|
|
|
|
blocks = [
|
|
|
|
{
|
|
|
|
block = "disk_space";
|
|
|
|
path = "/";
|
|
|
|
info_type = "available";
|
|
|
|
interval = 60;
|
|
|
|
warning = 20.0;
|
|
|
|
alert = 10.0;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
block = "memory";
|
2023-03-16 12:48:55 +01:00
|
|
|
format = " $icon mem_used_percents ";
|
|
|
|
format_alt = " $icon $swap_used_percents ";
|
2020-09-02 04:37:42 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
block = "cpu";
|
|
|
|
interval = 1;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
block = "load";
|
|
|
|
interval = 1;
|
2023-03-16 12:48:55 +01:00
|
|
|
format = " $icon $1m ";
|
2020-09-02 04:37:42 +02:00
|
|
|
}
|
|
|
|
{ block = "sound"; }
|
|
|
|
{
|
|
|
|
block = "time";
|
|
|
|
interval = 60;
|
2023-03-16 12:48:55 +01:00
|
|
|
format = " $timestamp.datetime(f:'%a %d/%m %R') ";
|
2020-09-02 04:37:42 +02:00
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2020-09-02 04:37:42 +02:00
|
|
|
Attribute set of i3status-rust bars, each with their own configuration.
|
2023-07-01 01:30:13 +02:00
|
|
|
Each bar {var}`name` generates a config file suffixed with
|
|
|
|
the bar's {var}`name` from the attribute set, like so:
|
|
|
|
{file}`config-''${name}.toml`.
|
|
|
|
|
2020-09-02 04:37:42 +02:00
|
|
|
This way, multiple config files can be generated, such as for having a
|
|
|
|
top and a bottom bar.
|
2023-07-01 01:30:13 +02:00
|
|
|
|
2020-09-02 04:37:42 +02:00
|
|
|
See
|
2023-07-01 01:30:13 +02:00
|
|
|
{manpage}`i3status-rust(1)`
|
2020-09-02 04:37:42 +02:00
|
|
|
for options.
|
|
|
|
'';
|
2021-10-09 11:14:08 +02:00
|
|
|
example = literalExpression ''
|
2020-09-02 04:37:42 +02:00
|
|
|
bottom = {
|
|
|
|
blocks = [
|
|
|
|
{
|
|
|
|
block = "disk_space";
|
|
|
|
path = "/";
|
|
|
|
info_type = "available";
|
|
|
|
interval = 60;
|
|
|
|
warning = 20.0;
|
|
|
|
alert = 10.0;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
block = "memory";
|
2023-03-16 12:48:55 +01:00
|
|
|
format_mem = " $icon $mem_used_percents ";
|
|
|
|
format_swap = " $icon $swap_used_percents ";
|
2020-09-02 04:37:42 +02:00
|
|
|
}
|
|
|
|
{
|
|
|
|
block = "cpu";
|
|
|
|
interval = 1;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
block = "load";
|
|
|
|
interval = 1;
|
2023-03-16 12:48:55 +01:00
|
|
|
format = " $icon $1m ";
|
2020-09-02 04:37:42 +02:00
|
|
|
}
|
|
|
|
{ block = "sound"; }
|
|
|
|
{
|
|
|
|
block = "time";
|
|
|
|
interval = 60;
|
2023-03-16 12:48:55 +01:00
|
|
|
format = " $timestamp.datetime(f:'%a %d/%m %R') ";
|
2020-09-02 04:37:42 +02:00
|
|
|
}
|
|
|
|
];
|
|
|
|
settings = {
|
|
|
|
theme = {
|
2023-03-16 12:48:55 +01:00
|
|
|
theme = "solarized-dark";
|
2020-09-02 04:37:42 +02:00
|
|
|
overrides = {
|
|
|
|
idle_bg = "#123456";
|
|
|
|
idle_fg = "#abcdef";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
icons = "awesome5";
|
|
|
|
theme = "gruvbox-dark";
|
|
|
|
};
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.i3status-rust;
|
2021-10-09 11:14:08 +02:00
|
|
|
defaultText = literalExpression "pkgs.i3status-rust";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = "Package providing i3status-rust";
|
2020-09-02 04:37:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2021-07-07 23:24:27 +02:00
|
|
|
assertions = [
|
|
|
|
(hm.assertions.assertPlatform "programs.i3status-rust" pkgs
|
|
|
|
platforms.linux)
|
2023-05-07 13:42:55 +02:00
|
|
|
{
|
|
|
|
assertion = lib.versionOlder cfg.package.version "0.31.0"
|
|
|
|
|| lib.versionAtLeast cfg.package.version "0.31.2";
|
|
|
|
message =
|
|
|
|
"Only i3status-rust <0.31.0 or ≥0.31.2 is supported due to a config format incompatibility.";
|
|
|
|
}
|
2021-07-07 23:24:27 +02:00
|
|
|
];
|
|
|
|
|
2020-09-02 04:37:42 +02:00
|
|
|
home.packages = [ cfg.package ];
|
|
|
|
|
2023-03-16 12:48:55 +01:00
|
|
|
xdg.configFile = mapAttrs' (cfgFileSuffix: cfgBar:
|
2020-09-02 04:37:42 +02:00
|
|
|
nameValuePair ("i3status-rust/config-${cfgFileSuffix}.toml") ({
|
2023-09-18 15:25:42 +02:00
|
|
|
onChange = ''
|
|
|
|
${pkgs.procps}/bin/pkill -u $USER -USR2 i3status-rs || true
|
2021-08-01 00:54:47 +02:00
|
|
|
'';
|
2020-09-02 04:37:42 +02:00
|
|
|
|
|
|
|
source = settingsFormat.generate ("config-${cfgFileSuffix}.toml") ({
|
2023-03-16 12:48:55 +01:00
|
|
|
theme = if lib.versionAtLeast cfg.package.version "0.30.0" then {
|
|
|
|
theme = cfgBar.theme;
|
|
|
|
} else
|
|
|
|
cfgBar.theme;
|
|
|
|
icons = if lib.versionAtLeast cfg.package.version "0.30.0" then {
|
|
|
|
icons = cfgBar.icons;
|
|
|
|
} else
|
|
|
|
cfgBar.icons;
|
|
|
|
block = cfgBar.blocks;
|
|
|
|
} // cfgBar.settings);
|
2020-09-02 04:37:42 +02:00
|
|
|
})) cfg.bars;
|
|
|
|
};
|
|
|
|
}
|