diff --git a/data/config b/data/config index b50a844..0e87922 100644 --- a/data/config +++ b/data/config @@ -32,6 +32,13 @@ WidgetsRight: [Tray, Packages, Audio, Bluetooth, Network, Disk, VRAM, GPU, RAM, # The CPU sensor to use CPUThermalZone: /sys/devices/pci0000:00/0000:00:18.3/hwmon/hwmon2/temp1_input +# The card to poll when using AMDGPU. If you don't have an AMD card, you can skip this config. +# Possible values can be found by querying /sys/class/drm +DrmAmdCard: card0 + +# Relative path to AMD gpu thermal sensor, appended after /sys/class/drm/ +AmdGPUThermalZone: /device/hwmon/hwmon1/temp1_input + # The command to execute on suspend SuspendCommand: ~/.config/scripts/sys.sh suspend @@ -160,10 +167,6 @@ NetworkAdapter: eno1 # Disables the network widget when set to false NetworkWidget: true -# The card to poll when using AMDGPU. If you don't have an AMD card, you can skip this config. -# Possible values can be found by querying /sys/class/drm -DrmAmdCard: card0 - # Use tooltips instead of sliders for the sensors SensorTooltips: false diff --git a/module.nix b/module.nix index 1efff2c..d897894 100644 --- a/module.nix +++ b/module.nix @@ -38,6 +38,16 @@ in { default = "/sys/devices/pci0000:00/0000:00:18.3/hwmon/hwmon2/temp1_input"; description = "path to the cpu thermal sensor, probably something in /sys/device"; }; + DrmAmdCard = mkOption { + type = types.nullOr types.str; + default = "card0"; + description = "AMD card to be queried for various system usage and temperature metrics. This can be found in /sys/class/drm"; + }; + AmdGPUThermalZone = mkOption { + type = types.nullOr types.str; + default = "/device/hwmon/hwmon1/temp1_input"; + description = "Relative path to AMD gpu thermal sensor, appended after /sys/class/drm/"; + }; SuspendCommand = mkOption { type = types.str; default = "systemctl suspend"; diff --git a/src/AMDGPU.h b/src/AMDGPU.h index a296e2b..bcd4709 100644 --- a/src/AMDGPU.h +++ b/src/AMDGPU.h @@ -10,8 +10,6 @@ namespace AMDGPU static const char* utilizationFile = "/device/gpu_busy_percent"; static const char* vramTotalFile = "/device/mem_info_vram_total"; static const char* vramUsedFile = "/device/mem_info_vram_used"; - // TODO: Make this configurable - static const char* tempFile = "/sys/class/drm/card0/device/hwmon/hwmon1/temp1_input"; inline void Init() { @@ -46,7 +44,8 @@ namespace AMDGPU return {}; } - std::ifstream file(drmCardPrefix + Config::Get().drmAmdCard + tempFile); + std::ifstream file(drmCardPrefix + Config::Get().drmAmdCard + Config::Get().amdGpuThermalZone); + std::string line; std::getline(file, line); return atoi(line.c_str()) / 1000; diff --git a/src/Config.cpp b/src/Config.cpp index 9359e70..f06e698 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -252,6 +252,7 @@ void Config::Load(const std::string& overrideConfigLocation) AddConfigVar("WidgetsRight", config.widgetsRight, lineView, foundProperty); AddConfigVar("CPUThermalZone", config.cpuThermalZone, lineView, foundProperty); + AddConfigVar("AmdGPUThermalZone", config.amdGpuThermalZone, lineView, foundProperty); AddConfigVar("NetworkAdapter", config.networkAdapter, lineView, foundProperty); AddConfigVar("DrmAmdCard", config.drmAmdCard, lineView, foundProperty); AddConfigVar("SuspendCommand", config.suspendCommand, lineView, foundProperty); diff --git a/src/Config.h b/src/Config.h index cb1e373..94e8eae 100644 --- a/src/Config.h +++ b/src/Config.h @@ -14,6 +14,7 @@ public: "VRAM", "GPU", "RAM", "CPU", "Battery", "Power"}; std::string cpuThermalZone = ""; // idk, no standard way of doing this. + std::string amdGpuThermalZone = "/device/hwmon/hwmon1/temp1_input"; std::string networkAdapter = "eno1"; // Is this standard? std::string drmAmdCard = "card0"; // The card to poll in AMDGPU. std::string suspendCommand = "systemctl suspend";