diff options
author | Michael Neumann <mneumann@ntecs.de> | 2015-08-16 17:34:16 +0200 |
---|---|---|
committer | Michael Neumann <mneumann@ntecs.de> | 2015-08-16 17:34:16 +0200 |
commit | 0e2f9ccf0c2e828bde790fb242a79adfa66f4a1d (patch) | |
tree | f18c1cc75c2757511d5a3fdcc6a84b1ba1b89de2 /libLumina | |
parent | DragonFly: Sync LOS::Checksums() with FreeBSD (diff) | |
download | lumina-0e2f9ccf0c2e828bde790fb242a79adfa66f4a1d.tar.gz lumina-0e2f9ccf0c2e828bde790fb242a79adfa66f4a1d.tar.bz2 lumina-0e2f9ccf0c2e828bde790fb242a79adfa66f4a1d.zip |
Implement CPUTemperatures() for DragonFly
Diffstat (limited to 'libLumina')
-rw-r--r-- | libLumina/LuminaOS-DragonFly.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/libLumina/LuminaOS-DragonFly.cpp b/libLumina/LuminaOS-DragonFly.cpp index 0dd10b88..13de5329 100644 --- a/libLumina/LuminaOS-DragonFly.cpp +++ b/libLumina/LuminaOS-DragonFly.cpp @@ -11,6 +11,7 @@ //can't read xbrightness settings - assume invalid until set static int screenbrightness = -1; static int audiovolume = -1; +static int ncpu = -1; QString LOS::OSName(){ return "DragonFly BSD"; } @@ -236,7 +237,24 @@ QString LOS::FileSystemCapacity(QString dir) { //Return: percentage capacity as } QStringList LOS::CPUTemperatures(){ //Returns: List containing the temperature of any CPU's ("50C" for example) - return QStringList(); //not implemented yet + QStringList temps; + + // Determine number of CPUs + if (ncpu == -1) { + ncpu = LUtils::getCmdOutput("sysctl -n hw.ncpu").join("").toInt(); + } + + // We couldn't get number of CPUs. Give up! + if (ncpu == -1) { + return temps; + } + + for (int cpu = 0; cpu < ncpu; ++cpu) { + QString cmd = QString("sysctl -n hw.sensors.cpu") + QString::number(cpu) + QString(".temp0"); + QString info = LUtils::getCmdOutput(cmd).join(""); + temps << info.section(" ", 0, 1); + } + return temps; } int LOS::CPUUsagePercent(){ //Returns: Overall percentage of the amount of CPU cycles in use (-1 for errors) |