aboutsummaryrefslogtreecommitdiff
path: root/libLumina/LuminaOS-OpenBSD.cpp
diff options
context:
space:
mode:
authorAntoine Jacoutot <ajacoutot@gnome.org>2015-01-23 10:24:36 +0100
committerAntoine Jacoutot <ajacoutot@gnome.org>2015-01-23 10:24:36 +0100
commit8ad0621d36061d5818986e7b107895b76b763b3e (patch)
tree68e1e8793b96a3f258fcf6f495adba97be3bc8c9 /libLumina/LuminaOS-OpenBSD.cpp
parentMerge branch 'master' of github.com:pcbsd/lumina (diff)
downloadlumina-8ad0621d36061d5818986e7b107895b76b763b3e.tar.gz
lumina-8ad0621d36061d5818986e7b107895b76b763b3e.tar.bz2
lumina-8ad0621d36061d5818986e7b107895b76b763b3e.zip
several OpenBSD improvements
Screen Brightness: make sure we are not running in a VM Check for user system permissionver: verbatim copy/paste from FreeBSD System Shutdown: shutdown -p is enough nowadays (no need for -hp) Battery Availability: fix battery detection
Diffstat (limited to 'libLumina/LuminaOS-OpenBSD.cpp')
-rw-r--r--libLumina/LuminaOS-OpenBSD.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/libLumina/LuminaOS-OpenBSD.cpp b/libLumina/LuminaOS-OpenBSD.cpp
index df6bcda7..a4d3a64b 100644
--- a/libLumina/LuminaOS-OpenBSD.cpp
+++ b/libLumina/LuminaOS-OpenBSD.cpp
@@ -50,6 +50,10 @@ QStringList LOS::ExternalDevicePaths(){
//Read screen brightness information
int LOS::ScreenBrightness(){
//Returns: Screen Brightness as a percentage (0-100, with -1 for errors)
+ //Make sure we are not running in a VM (does not work)
+ QStringList info = LUtils::getCmdOutput("sysctl -n hw.product");
+ if( !info.filter(QRegExp("VirtualBox|KVM")).isEmpty() ){ return -1; }
+ //Now perform the standard brightness checks
if(screenbrightness==-1){
if(QFile::exists(QDir::homePath()+"/.lumina/.currentxbrightness")){
int val = LUtils::readFile(QDir::homePath()+"/.lumina/.currentxbrightness").join("").simplified().toInt();
@@ -144,12 +148,14 @@ void LOS::startMixerUtility(){
//Check for user system permission (shutdown/restart)
bool LOS::userHasShutdownAccess(){
- return true; //not implemented yet
+ //User needs to be a part of the operator group to be able to run the shutdown command
+ QStringList groups = LUtils::getCmdOutput("id -Gn").join(" ").split(" ");
+ return groups.contains("operator");
}
//System Shutdown
void LOS::systemShutdown(){ //start poweroff sequence
- QProcess::startDetached("shutdown -hp now");
+ QProcess::startDetached("shutdown -p now");
}
//System Restart
@@ -159,8 +165,8 @@ void LOS::systemRestart(){ //start reboot sequence
//Battery Availability
bool LOS::hasBattery(){
- int val = LUtils::getCmdOutput("apm -l").join("").toInt();
- return (val >= 0 && val <= 100);
+ int val = LUtils::getCmdOutput("apm -b").join("").toInt();
+ return (val < 4);
}
//Battery Charge Level
bgstack15