diff options
-rw-r--r-- | debian/changelog | 8 | ||||
-rw-r--r-- | debian/control | 2 | ||||
-rw-r--r-- | libLumina/LuminaOS-Debian.cpp | 32 | ||||
-rw-r--r-- | libLumina/LuminaUtils.cpp | 4 |
4 files changed, 40 insertions, 6 deletions
diff --git a/debian/changelog b/debian/changelog index d8c39359..b65b5049 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +lumina-desktop (0.8.5.661-1nano) unstable; urgency=low + + * New git snapshot + - add dependency on top + - add support for cpu-usage and memory-usage in LuminaOS-Debian + + -- Christopher Roy Bratusek <nano@jpberlin.de> Fri, 22 May 2015 19:22:32 +0200 + lumina-desktop (0.8.5.638-1nano) unstable; urgency=low * New git snapshot diff --git a/debian/control b/debian/control index 36c0ee2f..3c71f0e9 100644 --- a/debian/control +++ b/debian/control @@ -20,7 +20,7 @@ Depends: ${misc:Depends}, ${shlibs:Depends}, libluminautils1 (= ${binary:Version lumina-xconfig, lumina-fileinfo, lxpolkit, lumina-data, fluxbox, numlockx, xbacklight, xscreensaver, usbmount, alsa-utils, acpi, gstreamer1.0-plugins-base, phonon4qt5-backend-gstreamer, - pavucontrol + pavucontrol, procps Recommends: qt5-configuration-tool Description: Lightweight Qt5-based desktop environment Metapackage depending on all other lumina packages. diff --git a/libLumina/LuminaOS-Debian.cpp b/libLumina/LuminaOS-Debian.cpp index e3aabeae..d1d5d344 100644 --- a/libLumina/LuminaOS-Debian.cpp +++ b/libLumina/LuminaOS-Debian.cpp @@ -138,7 +138,7 @@ void LOS::startMixerUtility(){ //Check for user system permission (shutdown/restart) bool LOS::userHasShutdownAccess(){ - QProcess::startDetached("dbus-send --system --print-reply=literal \ + return QProcess::startDetached("dbus-send --system --print-reply=literal \ --type=method_call --dest=org.freedesktop.login1 \ /org/freedesktop/login1 org.freedesktop.login1.Manager.CanPowerOff"); } @@ -159,7 +159,7 @@ void LOS::systemRestart(){ //start reboot sequence //Check for suspend support bool LOS::systemCanSuspend(){ - QProcess::startDetached("dbus-send --system --print-reply=literal \ + return QProcess::startDetached("dbus-send --system --print-reply=literal \ --type=method_call --dest=org.freedesktop.login1 \ /org/freedesktop/login1 org.freedesktop.login1.Manager.CanSuspend"); } @@ -236,15 +236,37 @@ 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 temp = LUtils::getCmdOutput("acpi -t").filter("degrees"); + for(int i=0; i<temp.length(); i++){ + if(temp[i].startsWith("Thermal")){ + temp[i] = temp[i].section(" ", 4, 6); + }else{ + temp.removeAt(i); i--; + } + } + qDebug() << "teperatures" << temp; + return temp; } int LOS::CPUUsagePercent(){ //Returns: Overall percentage of the amount of CPU cycles in use (-1 for errors) - return -1; //not implemented yet + QStringList info = LUtils::getCmdOutput("top -bn1").filter("Cpu(s)"); + if(info.isEmpty()){ return -1; } + QString idle = info.first().section(" ", 7, 7, QString::SectionSkipEmpty); + if(idle.isEmpty()){ return -1; } + else{ + return (100 - idle.toDouble()); + } } int LOS::MemoryUsagePercent(){ - return -1; //not implemented yet + QStringList mem = LUtils::getCmdOutput("top -bn1").filter("Mem:"); + if(mem.isEmpty()){ return -1; } + double fB = 0; //Free Bytes + double uB = 0; //Used Bytes + fB = mem.first().section(" ", 6, 6, QString::SectionSkipEmpty).toDouble(); + uB = mem.first().section(" ", 4, 4, QString::SectionSkipEmpty).toDouble(); + double per = (uB/(fB+uB)) * 100.0; + return qRound(per); } #endif diff --git a/libLumina/LuminaUtils.cpp b/libLumina/LuminaUtils.cpp index c9b13b8a..aa2336e3 100644 --- a/libLumina/LuminaUtils.cpp +++ b/libLumina/LuminaUtils.cpp @@ -43,6 +43,10 @@ int LUtils::runCmd(QString cmd, QStringList args){ QStringList LUtils::getCmdOutput(QString cmd, QStringList args){ QProcess proc; + QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); + env.insert("LANG", "C"); + env.insert("LC_MESSAGES", "C"); + proc.setProcessEnvironment(env); proc.setProcessChannelMode(QProcess::MergedChannels); if(args.isEmpty()){ proc.start(cmd); |