diff --git a/frontend/apps/reader/modules/readerfrontlight.lua b/frontend/apps/reader/modules/readerfrontlight.lua index e6c7623c2..d19d1c153 100644 --- a/frontend/apps/reader/modules/readerfrontlight.lua +++ b/frontend/apps/reader/modules/readerfrontlight.lua @@ -63,7 +63,7 @@ function ReaderFrontLight:onShowIntensity() local powerd = Device:getPowerDevice() if powerd.fl_intensity ~= nil then UIManager:show(Notification:new{ - text = T( _("Frontlight intensity is set to %1."), powerd.fl_intensity), + text = T(_("Frontlight intensity is set to %1."), powerd.fl_intensity), timeout = 1.0, }) end diff --git a/frontend/device/kobo/nickel_conf.lua b/frontend/device/kobo/nickel_conf.lua index 57aca7ac1..2cfcceb05 100644 --- a/frontend/device/kobo/nickel_conf.lua +++ b/frontend/device/kobo/nickel_conf.lua @@ -73,7 +73,7 @@ function NickelConf.frontLightState.get() return new_state end -function NickelConf._write_kobo_conf(re_Match, key, value) +function NickelConf._write_kobo_conf(re_Match, key, value, dont_create) local kobo_conf = io.open(kobo_conf_path, "r") local lines = {} local found = false @@ -108,7 +108,7 @@ function NickelConf._write_kobo_conf(re_Match, key, value) kobo_conf:close() end - if not found then + if not found and dont_create ~= true then if not correct_section then lines[#lines + 1] = "[PowerOptions]" end @@ -140,7 +140,9 @@ function NickelConf.frontLightState.set(new_state) "Wrong front light state value type (expect boolean)!") return NickelConf._write_kobo_conf(re_FrontLightState, front_light_state_str, - new_state) + new_state, + -- do not create this entry is missing + true) end return NickelConf diff --git a/spec/unit/nickel_conf_spec.lua b/spec/unit/nickel_conf_spec.lua index 44beba96b..3e9f648f4 100644 --- a/spec/unit/nickel_conf_spec.lua +++ b/spec/unit/nickel_conf_spec.lua @@ -59,7 +59,7 @@ bar=baz NickelConf._set_kobo_conf_path(fn) assert.Equals(NickelConf.frontLightLevel.get(), 20) - assert.Equals(NickelConf.frontLightState.get(), false) + assert.Equals(NickelConf.frontLightState.get(), nil) os.remove(fn) end) @@ -83,7 +83,6 @@ FrontLightLevel=6 FrontLightLevel=6 [PowerOptions] FrontLightLevel=100 -FrontLightState=true ]]) fd:close() os.remove(fn) @@ -99,7 +98,6 @@ FrontLightState=true assert.Equals(fd:read("*a"), [[ [PowerOptions] FrontLightLevel=20 -FrontLightState=false ]]) fd:close() os.remove(fn) @@ -153,14 +151,13 @@ bar=baz NickelConf.frontLightState.set(true) fd = io.open(fn, "r") - assert.Equals(fd:read("*a"), [[ + assert.Equals([[ [PowerOptions] foo=bar FrontLightLevel=1 -FrontLightState=true [OtherThing] bar=baz -]]) +]], fd:read("*a")) fd:close() os.remove(fn) end) @@ -178,7 +175,6 @@ bar=baz assert.Equals([[ [PowerOptions] FrontLightLevel=15 -FrontLightState=false ]], fd:read("*a")) fd:close()