aboutsummaryrefslogtreecommitdiff
path: root/libLumina/LuminaOS-FreeBSD.cpp
diff options
context:
space:
mode:
authorwi <william.os4y@gmail.com>2015-04-20 21:53:25 +0200
committerwi <william.os4y@gmail.com>2015-04-20 21:53:25 +0200
commita33566d53dab6f5bf3d4b6663014b6b548446525 (patch)
tree6e57deaa6afc289cb6a51a523e2fb1530830bd9c /libLumina/LuminaOS-FreeBSD.cpp
parentThis is a complete adaptation of lumina-fileinfo. (diff)
parentAdd a special flag to prevent the lumina-open crash handler from starting up ... (diff)
downloadlumina-a33566d53dab6f5bf3d4b6663014b6b548446525.tar.gz
lumina-a33566d53dab6f5bf3d4b6663014b6b548446525.tar.bz2
lumina-a33566d53dab6f5bf3d4b6663014b6b548446525.zip
Merge remote-tracking branch 'upstream/master' into deskEditor
Diffstat (limited to 'libLumina/LuminaOS-FreeBSD.cpp')
-rw-r--r--libLumina/LuminaOS-FreeBSD.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/libLumina/LuminaOS-FreeBSD.cpp b/libLumina/LuminaOS-FreeBSD.cpp
index 73637048..c9874605 100644
--- a/libLumina/LuminaOS-FreeBSD.cpp
+++ b/libLumina/LuminaOS-FreeBSD.cpp
@@ -8,6 +8,7 @@
#include "LuminaOS.h"
#include <unistd.h>
+#include <QDebug>
//can't read xbrightness settings - assume invalid until set
static int screenbrightness = -1;
@@ -71,17 +72,18 @@ void LOS::setScreenBrightness(int percent){
//ensure bounds
if(percent<0){percent=0;}
else if(percent>100){ percent=100; }
- float pf = percent/100.0; //convert to a decimel
//Run the command(s)
bool success = false;
// - try hardware setting first (PC-BSD only)
if(QFile::exists("/usr/local/bin/pc-sysconfig")){
- QString ret = LUtils::getCmdOutput("pc-sysconfig \"setscreenbrightness "+QString::number(percent)+"\"").join("");
- success = (ret.simplified() == "[SUCCESS]");
+ QString ret = LUtils::getCmdOutput("pc-sysconfig", QStringList() <<"setscreenbrightness "+QString::number(percent)).join("");
+ success = ret.toLower().contains("success");
+ qDebug() << "Set hardware brightness:" << percent << success;
}
// - if hardware brightness does not work, use software brightness
if(!success){
QString cmd = "xbrightness %1";
+ float pf = percent/100.0; //convert to a decimel
cmd = cmd.arg( QString::number( int(65535*pf) ) );
success = (0 == LUtils::runCmd(cmd) );
}
@@ -169,6 +171,22 @@ void LOS::systemRestart(){ //start reboot sequence
QProcess::startDetached("shutdown -ro now");
}
+//Check for suspend support
+bool LOS::systemCanSuspend(){
+ //This will only function on PC-BSD
+ //(permissions issues on standard FreeBSD unless setup a special way)
+ bool ok = QFile::exists("/usr/local/bin/pc-sysconfig");
+ if(ok){
+ ok = LUtils::getCmdOutput("pc-sysconfig systemcansuspend").join("").toLower().contains("true");
+ }
+ return ok;
+}
+
+//Put the system into the suspend state
+void LOS::systemSuspend(){
+ QProcess::startDetached("pc-sysconfig suspendsystem");
+}
+
//Battery Availability
bool LOS::hasBattery(){
int val = LUtils::getCmdOutput("apm -l").join("").toInt();
bgstack15