diff options
Diffstat (limited to 'libLumina')
-rw-r--r-- | libLumina/LuminaOS-DragonFly.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libLumina/LuminaOS-DragonFly.cpp b/libLumina/LuminaOS-DragonFly.cpp index 79f84e65..2f9beb4b 100644 --- a/libLumina/LuminaOS-DragonFly.cpp +++ b/libLumina/LuminaOS-DragonFly.cpp @@ -58,21 +58,27 @@ int LOS::ScreenBrightness(){ screenbrightness = val; } } + //If it gets to this point, then we have a valid (but new) installation + if(screenbrightness<0){ screenbrightness = 100; } //default value for systems + return screenbrightness; } //Set screen brightness void LOS::setScreenBrightness(int percent){ + if(percent == -1){ return; } //This is usually an invalid value passed directly to the setter //ensure bounds if(percent<0){percent=0;} else if(percent>100){ percent=100; } + //Run the command(s) + bool success = false; float pf = percent/100.0; //convert to a decimel //Run the command QString cmd = "xbrightness %1"; cmd = cmd.arg( QString::number( int(65535*pf) ) ); - int ret = LUtils::runCmd(cmd); + success = (0 == LUtils::runCmd(cmd) ); //Save the result for later - if(ret!=0){ screenbrightness = -1; } + if(!success){ screenbrightness = -1; } else{ screenbrightness = percent; } LUtils::writeFile(QDir::homePath()+"/.lumina/.currentxbrightness", QStringList() << QString::number(screenbrightness), true); } |