nixos-config/home/x/i3bar.nix

159 lines
4.1 KiB
Nix
Raw Permalink Normal View History

2022-04-10 11:54:58 +02:00
{
config,
lib,
pkgs,
...
}: let
inherit
(lib)
2022-01-11 16:08:21 +01:00
lists
mkIf
mkOption
optional
types
2022-04-10 11:54:58 +02:00
;
2022-01-11 16:08:21 +01:00
2021-04-19 14:58:52 +02:00
isEnabled = config.my.home.x.enable;
2021-04-22 02:33:39 +02:00
i3BarTheme = config.my.theme.i3BarTheme;
cfg = config.my.home.x.i3bar;
2022-04-10 11:54:58 +02:00
in {
2022-01-11 16:08:21 +01:00
options.my.home.x.i3bar = {
temperature.chip = mkOption {
type = types.str;
example = "coretemp-isa-*";
default = "";
};
temperature.inputs = mkOption {
type = types.listOf types.str;
example = ["Core 0" "Core 1" "Core 2" "Core 3"];
default = "";
};
networking.throughput_interfaces = mkOption {
type = types.listOf types.str;
2022-04-10 11:54:58 +02:00
example = ["wlp1s0"];
default = [];
};
};
2021-04-19 22:54:20 +02:00
2022-01-11 16:08:21 +01:00
config = mkIf isEnabled {
home.packages = builtins.attrValues {
2022-04-10 11:54:58 +02:00
inherit
(pkgs)
# FIXME: is this useful?
2022-04-10 11:54:58 +02:00
2022-01-11 16:08:21 +01:00
font-awesome
2022-04-10 11:54:58 +02:00
;
2022-01-11 16:08:21 +01:00
};
2021-04-19 14:58:52 +02:00
programs.i3status-rust = {
enable = true;
bars = {
top = {
2021-04-19 22:54:20 +02:00
icons = "awesome5";
settings.theme = {
theme = i3BarTheme.theme.name;
overrides = i3BarTheme.theme.overrides;
};
2021-04-19 22:54:20 +02:00
2022-04-10 11:54:58 +02:00
blocks =
[
{
block = "pomodoro";
notify_cmd = "i3nag";
blocking_cmd = true;
2022-04-10 11:54:58 +02:00
}
{
block = "disk_space";
path = "/";
info_type = "available";
interval = 60;
warning = 20.0;
alert = 10.0;
alert_unit = "GB";
2022-04-10 11:54:58 +02:00
}
{
block = "memory";
format = " $icon $mem_used.eng(prefix:G)/$mem_total.eng(prefix:G) ";
2022-04-10 11:54:58 +02:00
warning_mem = 70.0;
critical_mem = 90.0;
}
{
block = "cpu";
interval = 1;
format = " $icon $barchart ";
2022-04-10 11:54:58 +02:00
}
{
block = "temperature";
interval = 10;
format = " $icon $max ";
2022-04-10 11:54:58 +02:00
chip = cfg.temperature.chip;
inputs = cfg.temperature.inputs;
}
{
block = "custom";
# TODO: get service name programmatically somehow
command = let
systemctl = lib.getExe' pkgs.systemd "systemctl";
in
pkgs.writeShellScript "check-restic.sh" ''
BACKUP_STATUS=Good
if ${systemctl} is-failed --quiet restic-backups-backblaze.service; then
BACKUP_STATUS=Critical
fi
echo "{\"state\": \"$BACKUP_STATUS\", \"text\": \"Backup\"}"
'';
json = true;
interval = 60;
}
2022-04-10 11:54:58 +02:00
]
++ (
lists.optionals ((builtins.length cfg.networking.throughput_interfaces) != 0)
(map
(interface: {
block = "net";
device = interface;
interval = 1;
missing_format = "";
})
2022-04-10 11:54:58 +02:00
cfg.networking.throughput_interfaces)
)
++ [
{
block = "net";
format = " $icon {$ip|} {SSID: $ssid|}";
theme_overrides = {
idle_bg = {link = "good_bg";};
idle_fg = {link = "good_fg";};
};
2022-04-10 11:54:58 +02:00
}
{
block = "sound";
driver = "pulseaudio";
}
]
++ (
optional config.my.home.laptop.enable
{
block = "battery";
format = " $icon $percentage ($power) ";
2022-04-10 11:54:58 +02:00
}
)
++ [
# {
# block = "notify";
# }
{
block = "time";
interval = 5;
format = " $icon $timestamp.datetime(f:'%a %d/%m %T', l:fr_FR) ";
2022-04-10 11:54:58 +02:00
timezone = "Europe/Paris";
}
];
2021-04-19 14:58:52 +02:00
};
};
};
};
}