mirror of
https://github.com/scorpion-26/gBar.git
synced 2024-11-23 11:42:51 +00:00
Add configurable gpu thermal zone (#89)
There is a bug where the `tempFile` was the entire path (instead of just the subpath) leading to some issues. This commit fixes that and also adds an option to set the entire path.
This commit is contained in:
parent
3a7ff0d179
commit
b3f037db5b
5 changed files with 21 additions and 7 deletions
11
data/config
11
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/<DrmAmdCard>
|
||||
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
|
||||
|
||||
|
|
10
module.nix
10
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/<DrmAmdCard>";
|
||||
};
|
||||
SuspendCommand = mkOption {
|
||||
type = types.str;
|
||||
default = "systemctl suspend";
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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";
|
||||
|
|
Loading…
Reference in a new issue