mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
DO NOT MERGE initial suspend support for Kobo
This commit is contained in:
2
Makefile
2
Makefile
@@ -13,7 +13,7 @@ INSTALL_DIR=koreader-$(MACHINE)
|
||||
|
||||
# files to link from main directory
|
||||
INSTALL_FILES=reader.lua frontend resources koreader.sh \
|
||||
koreader_kobo.sh defaults.lua \
|
||||
koreader_kobo.sh kobo_suspend.sh defaults.lua \
|
||||
git-rev README.md COPYING
|
||||
|
||||
# for gettext
|
||||
|
||||
@@ -152,6 +152,24 @@ function Device:outofScreenSaver()
|
||||
self.screen_saver_mode = false
|
||||
end
|
||||
|
||||
function Device:Suspend()
|
||||
UIManager:show(InfoMessage:new{
|
||||
text = _("Standby"),
|
||||
timeout = 4,
|
||||
})
|
||||
if self.fl ~= nil then
|
||||
self.fl:sleep()
|
||||
end
|
||||
os.execute("./kobo_suspend.sh &")
|
||||
end
|
||||
|
||||
function Device:Resume()
|
||||
if self.fl ~= nil then
|
||||
self.fl:resume()
|
||||
end
|
||||
-- Screen:refresh(0)
|
||||
end
|
||||
|
||||
function Device:usbPlugIn()
|
||||
--os.execute("echo 'usb in' >> /mnt/us/event_test.txt")
|
||||
if self.charging_mode == false and self.screen_saver_mode == false then
|
||||
|
||||
@@ -423,6 +423,15 @@ function Input:handleKeyBoardEv(ev)
|
||||
return keycode
|
||||
end
|
||||
|
||||
-- Kobo sleep
|
||||
if keycode == "Power" then
|
||||
if ev.value == EVENT_VALUE_KEY_PRESS then
|
||||
return "Suspend"
|
||||
else
|
||||
return "Resume"
|
||||
end
|
||||
end
|
||||
|
||||
if ev.value == EVENT_VALUE_KEY_RELEASE
|
||||
and keycode == "Light" then
|
||||
return keycode
|
||||
|
||||
@@ -293,6 +293,10 @@ function UIManager:run()
|
||||
Device:usbPlugOut()
|
||||
elseif input_event == "Light" then
|
||||
Device:getFrontlight():toggle()
|
||||
elseif input_event == "Suspend" then
|
||||
Device:Suspend()
|
||||
elseif input_event == "Resume" then
|
||||
Device:Resume()
|
||||
else
|
||||
self:sendEvent(input_event)
|
||||
end
|
||||
|
||||
30
kobo_suspend.sh
Normal file
30
kobo_suspend.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/bin/sh
|
||||
export PATH=$PATH:/sbin:/usr/sbin
|
||||
|
||||
ts_file=/tmp/back_from_suspend
|
||||
|
||||
if test -e $ts_file ; then
|
||||
sec_back_suspend=$(stat -t $ts_file | awk '{print $13}' )
|
||||
delta_sec=$(( $(date +%s) - $sec_back_suspend ))
|
||||
echo sec_back_suspend=$sec_back_suspend delta_sec=$delta_sec >> /tmp/event_test.txt
|
||||
test $delta_sec -gt 2 || exit
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
|
||||
if lsmod | grep -q sdio_wifi_pwr ; then
|
||||
wlarm_le -i eth0 down
|
||||
ifconfig eth0 down
|
||||
/sbin/rmmod -r dhd
|
||||
/sbin/rmmod -r sdio_wifi_pwr
|
||||
fi
|
||||
|
||||
|
||||
sleep 1
|
||||
|
||||
sync
|
||||
echo 1 > /sys/power/state-extended
|
||||
echo mem > /sys/power/state
|
||||
echo 0 > /sys/power/state-extended
|
||||
|
||||
touch $ts_file
|
||||
Reference in New Issue
Block a user