diff options
Diffstat (limited to 'gui/blanktimer.cpp')
-rw-r--r-- | gui/blanktimer.cpp | 40 |
1 files changed, 11 insertions, 29 deletions
diff --git a/gui/blanktimer.cpp b/gui/blanktimer.cpp index 383b15724..1b184297b 100644 --- a/gui/blanktimer.cpp +++ b/gui/blanktimer.cpp @@ -97,11 +97,11 @@ int blanktimer::setClockTimer(void) { if (sleepTimer > 2 && diff.tv_sec > (sleepTimer - 2) && conblank == 0) { orig_brightness = getBrightness(); setConBlank(1); - setBrightness(5); + TWFunc::Set_Brightness("5"); } if (sleepTimer && diff.tv_sec > sleepTimer && conblank < 2) { setConBlank(2); - setBrightness(0); + TWFunc::Set_Brightness("0"); screenoff = true; TWFunc::check_and_run_script("/sbin/postscreenblank.sh", "blank"); PageManager::ChangeOverlay("lock"); @@ -115,39 +115,20 @@ int blanktimer::setClockTimer(void) { return -1; //shouldn't get here } -int blanktimer::getBrightness(void) { - string results; +string blanktimer::getBrightness(void) { + string result; string brightness_path; DataManager::GetValue("tw_brightness_file", brightness_path); - if ((TWFunc::read_file(brightness_path, results)) != 0) - return -1; - int result = atoi(results.c_str()); - if (result == 0) { - int tw_brightness; - DataManager::GetValue("tw_brightness", tw_brightness); - if (tw_brightness) { - result = tw_brightness; - } else { - result = 255; - } + if (brightness_path == "/nobrightness") + return brightness_path; + DataManager::GetValue("tw_brightness", result); + if (result == "") { + result = "255"; } return result; } -int blanktimer::setBrightness(int brightness) { - string brightness_path; - string bstring; - char buff[100]; - DataManager::GetValue("tw_brightness_file", brightness_path); - sprintf(buff, "%d", brightness); - bstring = buff; - if ((TWFunc::write_file(brightness_path, bstring)) != 0) - return -1; - gui_forceRender(); - return 0; -} - void blanktimer::resetTimerAndUnblank(void) { setTimer(); switch (conblank) { @@ -165,7 +146,8 @@ void blanktimer::resetTimerAndUnblank(void) { screenoff = false; // No break here, we want to keep going case 1: - setBrightness(orig_brightness); + if (orig_brightness != "/nobrightness") + TWFunc::Set_Brightness(orig_brightness); setConBlank(0); break; } |