Add variables for thermal monitoring on waybar

This commit is contained in:
Yorick Barbanneau 2024-02-19 00:16:54 +01:00
parent 51142c3af0
commit de6fb52e25
2 changed files with 71 additions and 7 deletions

View file

@ -12,6 +12,43 @@ in
default = false; default = false;
description = "configure laptop mode"; description = "configure laptop mode";
}; };
waybar = {
laptop = mkOption {
type = types.bool;
default = false;
description = "Enable laptop element on Waybar";
};
cpuThermal = {
hwmonPathAbs = mkOption {
type = types.str;
default = "";
description = "CPU thermal hwmon absolute path";
};
inputFilename = mkOption {
type = types.str;
default = "";
description = "CPU thermal hwmon file";
};
};
gpuThermal = {
enable = mkOption {
type = types.bool;
default = false;
description = "enable waybar GPU temperature";
};
hmonPath = mkOption {
type = types.str;
default = "";
description = "Thermal zone for CPU";
};
};
};
}; };
imports = [ imports = [
./includes/fuzzel.nix ./includes/fuzzel.nix

View file

@ -1,7 +1,10 @@
{config, lib, ...}: {lib, config, ...}:
with lib; with lib;
let
cfg = config.modules.desktop.sway;
in
{ {
config = mkIf config.modules.desktop.sway.enable { config = mkIf cfg.enable {
programs.waybar = { programs.waybar = {
enable = true; enable = true;
systemd = { systemd = {
@ -21,12 +24,30 @@ with lib;
modules-right = [ modules-right = [
"network" "network"
"custom/sep" "custom/sep"
"backlight" ] ++ (
"battery" if cfg.waybar.laptop then [
"custom/sep" "backlight"
"battery"
"custom/sep"
]
else [
]
) ++
[
"memory" "memory"
"cpu" "cpu"
"temperature"
"custom/sep" "custom/sep"
] ++ (
if cfg.waybar.gpuThermal.enable then [
"temperature#gpu"
"custom/sep"
]
else [
]
) ++
[
"pulseaudio" "pulseaudio"
"custom/sep" "custom/sep"
"clock" "clock"
@ -100,7 +121,13 @@ with lib;
"temperature" = { "temperature" = {
"critical-threshold" = 80; "critical-threshold" = 80;
"format" = "{temperatureC}°C "; "format" = "{temperatureC}°C ";
"thermal-zone" = "6"; "hwmon-path-abs" = "${cfg.waybar.cpuThermal.hwmonPathAbs}";
"input-filename" = "${cfg.waybar.cpuThermal.inputFilename}";
};
"temperature#gpu" = {
"critical-threshold" = 80;
"format" = "GPU: {temperatureC}°C ";
"hwmon-path" = "${cfg.waybar.gpuThermal.hmonPath}";
}; };
"backlight" = { "backlight" = {
"format" = "{percent}% {icon}"; "format" = "{percent}% {icon}";