From d1e8b8098d8682fac91174233aed846f416e70e9 Mon Sep 17 00:00:00 2001 From: hzj-jie Date: Sun, 27 Mar 2016 23:57:11 -0700 Subject: [PATCH] Koreader won't start on Kobo without frontlight, powerd.fl may be nil. --- reader.lua | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/reader.lua b/reader.lua index f9591a692..162b03b0a 100755 --- a/reader.lua +++ b/reader.lua @@ -117,22 +117,24 @@ end -- restore kobo frontlight settings and probe kobo touch coordinates if Device:isKobo() then - local powerd = Device:getPowerDevice() - if powerd and powerd.restore_settings then - -- UIManager:init() should have sanely set up the frontlight_stuff by this point - local intensity = G_reader_settings:readSetting("frontlight_intensity") - powerd.fl_intensity = intensity or powerd.fl_intensity - local is_frontlight_on = G_reader_settings:readSetting("is_frontlight_on") - if is_frontlight_on then - -- default powerd.is_fl_on is false, turn it on - powerd:toggleFrontlight() - else - -- the light can still be turned on manually outside of koreader - -- or nickel. so we always set the intensity to 0 here to keep it - -- in sync with powerd.is_fl_on (false by default) - -- NOTE: we cant use setIntensity method here because for kobo the - -- min intensity is 1 :( - powerd.fl:setBrightness(0) + if Device.hasFrontlight then + local powerd = Device:getPowerDevice() + if powerd and powerd.restore_settings then + -- UIManager:init() should have sanely set up the frontlight_stuff by this point + local intensity = G_reader_settings:readSetting("frontlight_intensity") + powerd.fl_intensity = intensity or powerd.fl_intensity + local is_frontlight_on = G_reader_settings:readSetting("is_frontlight_on") + if is_frontlight_on then + -- default powerd.is_fl_on is false, turn it on + powerd:toggleFrontlight() + else + -- the light can still be turned on manually outside of koreader + -- or nickel. so we always set the intensity to 0 here to keep it + -- in sync with powerd.is_fl_on (false by default) + -- NOTE: we cant use setIntensity method here because for kobo the + -- min intensity is 1 :( + powerd.fl:setBrightness(0) + end end end if Device:getCodeName() == "trilogy" then