aboutsummaryrefslogtreecommitdiff
path: root/libLumina/LuminaOS-DragonFly.cpp
diff options
context:
space:
mode:
authorMichael Neumann <mneumann@ntecs.de>2015-08-16 17:34:16 +0200
committerMichael Neumann <mneumann@ntecs.de>2015-08-16 17:34:16 +0200
commit0e2f9ccf0c2e828bde790fb242a79adfa66f4a1d (patch)
treef18c1cc75c2757511d5a3fdcc6a84b1ba1b89de2 /libLumina/LuminaOS-DragonFly.cpp
parentDragonFly: Sync LOS::Checksums() with FreeBSD (diff)
downloadlumina-0e2f9ccf0c2e828bde790fb242a79adfa66f4a1d.tar.gz
lumina-0e2f9ccf0c2e828bde790fb242a79adfa66f4a1d.tar.bz2
lumina-0e2f9ccf0c2e828bde790fb242a79adfa66f4a1d.zip
Implement CPUTemperatures() for DragonFly
Diffstat (limited to 'libLumina/LuminaOS-DragonFly.cpp')
-rw-r--r--libLumina/LuminaOS-DragonFly.cpp20
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)
bgstack15