Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Readers > Amazon Kindle > Kindle Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 12-03-2012, 09:00 PM   #1
dos1
20% cooler.
dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.
 
dos1's Avatar
 
Posts: 92
Karma: 364538
Join Date: Oct 2012
Location: Poznań, Poland
Device: Kindle Paperwhite
eventHandler - easy way to run scripts on boot and screensaver on/off events

I've just created a small package for Kindle Touch and Paperwhite.
(please note that it's untested on Touch, but it should work)

I don't know if anything like that already exists. I just created it for myself and now decided to learn how to package stuff with kindletool

It's a very simple shell script used to run other shell scripts on particular events - boot, suspend or resume. Boot is self-explanatory, suspend is going to screen saver and resume is returning from screen saver.

After installing eventHandler you'll see a scripts directory created in your user partition. It contains three subdirectories - boot, suspend and resume. When event occurs, eventHandler runs all scripts in directory matching given event.

It's simple as that This gives you possibility to run simple scripts without having to install usb networking and other advanced stuff. You'll just need a jailbreak.

Installing is easy: just put install file in root directory of user partition and select "Update your Kindle" from Settings screen. Uninstalling follows the same pattern.

Package contains also few scripts used by me which can be taken as examples:

Spoiler:
screensaver changes behavior of screen saver rotating from ordered to random. Please note that it expects all wallpapers to be named like bg_medium_ss01.png, with leading zero if number is smaller than 10. Should be put under resume directory.
NOTE: Of course it will only work when Special Offers are disabled. If you have SO Kindle, please don't ask how to remove ads. Figure it by yourself or pay Amazon to remove them. Thank you.

wpa-eap can be used to support WPA-EAP WiFi network with client certificate, like one on my university. You'll need to adapt settings to your configuration - passphrase, paths to certificates etc. Should be put under both boot and resume directory.

rss can be used to emulate push-to-Kindle functionality from Amazon, but using your own server. It allows you for instance to synchronize your Kindle with automatically generated RSS feeds from Calibre without duplicated entries, like it happens when using Amazons e-mail pushing. It uses titlebar notifications and checks for timestamp to minimize battery usage on each resume, so it won't synchronize when not needed. Again, you'll need to configure it. It will work without any changes, but you probably don't want to synchronize with my feeds (I left my configuration to allow you checking by yourselves how it should be configured on the server). It stores files in /mnt/us/documents/RSS


Please note that example scripts are only tested on Paperwhite.

NOTE: eventHandler runs all your scripts as root, so be careful with what you include in your scripts! Running "rm -rf /" isn't probably a good idea

If you have Kindle Touch or Kindle Paperwhite, install kindle5 version.
If you have non-touch Kindle 4, install kindle4 version.
Please note that Kindle 4 version is untested!

Enjoy!

[edit]
Updated to 0.11 version which should fix bug reported by stepk and which brings (untested) install files for Kindle 4 (non-touch).

[edit]
Updated to 0.2 version which now works properly with magnetic cover.
Attached Files
File Type: gz eventHandler-0.2.tar.gz (16.3 KB, 260 views)

Last edited by dos1; 03-01-2013 at 06:20 PM. Reason: update to 0.2
dos1 is offline   Reply With Quote
Old 12-03-2012, 09:02 PM   #2
qlob
Official Lurker
qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.
 
qlob's Avatar
 
Posts: 1,048
Karma: 7096675
Join Date: Apr 2012
Device: Kindle 3.4
It's almost like Kite! (but lacking in the launching scripts from the home screen area...)

Looks fancy though... It would be cool to write this for the K3 or K4 as well.
qlob is offline   Reply With Quote
Old 12-04-2012, 02:13 PM   #3
stepk
Groupie
stepk ought to be getting tired of karma fortunes by now.stepk ought to be getting tired of karma fortunes by now.stepk ought to be getting tired of karma fortunes by now.stepk ought to be getting tired of karma fortunes by now.stepk ought to be getting tired of karma fortunes by now.stepk ought to be getting tired of karma fortunes by now.stepk ought to be getting tired of karma fortunes by now.stepk ought to be getting tired of karma fortunes by now.stepk ought to be getting tired of karma fortunes by now.stepk ought to be getting tired of karma fortunes by now.stepk ought to be getting tired of karma fortunes by now.
 
Posts: 164
Karma: 593450
Join Date: Oct 2012
Device: K5 B011 5.3.2.1
Thanks for this. Unfortunately install.sh fails on my KT because it assumes that /usr/local exists, while it really doesn't - on my almost untouched KT.
stepk is offline   Reply With Quote
Old 12-04-2012, 02:17 PM   #4
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,552
Karma: 6021142
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
I had an issue in DIAGS where it (booting diags) would clean down my /usr/local

Never not had one. Good point though.

best to do a [ -e ] or z or f or whatever I suppose

YAY CORNER CASES!
twobob is offline   Reply With Quote
Old 12-04-2012, 02:51 PM   #5
dos1
20% cooler.
dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.
 
dos1's Avatar
 
Posts: 92
Karma: 364538
Join Date: Oct 2012
Location: Poznań, Poland
Device: Kindle Paperwhite
Quote:
Originally Posted by stepk View Post
Thanks for this. Unfortunately install.sh fails on my KT because it assumes that /usr/local exists, while it really doesn't - on my almost untouched KT.
Should be now fixed, could you try again please?

BTW. I've included version for Kindle 4, could someone test if it works? (note that example scripts probably won't work without adjusting)
dos1 is offline   Reply With Quote
Old 12-04-2012, 03:16 PM   #6
stepk
Groupie
stepk ought to be getting tired of karma fortunes by now.stepk ought to be getting tired of karma fortunes by now.stepk ought to be getting tired of karma fortunes by now.stepk ought to be getting tired of karma fortunes by now.stepk ought to be getting tired of karma fortunes by now.stepk ought to be getting tired of karma fortunes by now.stepk ought to be getting tired of karma fortunes by now.stepk ought to be getting tired of karma fortunes by now.stepk ought to be getting tired of karma fortunes by now.stepk ought to be getting tired of karma fortunes by now.stepk ought to be getting tired of karma fortunes by now.
 
Posts: 164
Karma: 593450
Join Date: Oct 2012
Device: K5 B011 5.3.2.1
OK, it's working now, thanks.
How do you generate the server content for the rss feed script? I mean, do you run the calibre client on a debian box and save generated .pobi files to the http server, or do you run calibre as a content server?
stepk is offline   Reply With Quote
Old 12-04-2012, 03:17 PM   #7
dos1
20% cooler.
dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.
 
dos1's Avatar
 
Posts: 92
Karma: 364538
Join Date: Oct 2012
Location: Poznań, Poland
Device: Kindle Paperwhite
Quote:
Originally Posted by stepk View Post
OK, it's working now, thanks.
How do you generate the server content for the rss feed script? I mean, do you run the calibre client on a debian box and save generated .pobi files to the http server, or do you run calibre as a content server?
I have installed Calibre on my VPS and created cron jobs for updating pobi files in specified directory, which is exported to the world via rsync daemon.
dos1 is offline   Reply With Quote
Old 03-01-2013, 06:22 PM   #8
dos1
20% cooler.
dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.dos1 ought to be getting tired of karma fortunes by now.
 
dos1's Avatar
 
Posts: 92
Karma: 364538
Join Date: Oct 2012
Location: Poznań, Poland
Device: Kindle Paperwhite
0.2 version is now up - I've fixed a bug which prevented scripts from being launched when using magnetic cover. Enjoy!
dos1 is offline   Reply With Quote
Old 03-01-2013, 11:20 PM   #9
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,552
Karma: 6021142
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
ROCK HANDS!!!
twobob is offline   Reply With Quote
Old 05-25-2013, 07:36 AM   #10
Vava
Member
Vava began at the beginning.
 
Posts: 17
Karma: 10
Join Date: May 2013
Device: PaperWhite
Thanks you for this package !
I have an issue with the startup script. I would like to run a web browser (this one http://www.mobileread.com/forums/sho...d.php?t=210210) at startup. The application is well opened but few secondes later the classic menu comes back. When I launch it from the suspend or resume script, it works fine. My first guess was that the browser finished his launching before the Kindle. Did you ever notice this kind of problem ?
Vava is offline   Reply With Quote
Old 05-25-2013, 07:39 AM   #11
thomass
Wizard
thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.thomass ought to be getting tired of karma fortunes by now.
 
Posts: 1,635
Karma: 1915537
Join Date: Mar 2011
Location: Türkiye
Device: Kindle 5.3.7
Quote:
Originally Posted by Vava View Post
The application is well opened but few secondes later the classic menu comes back.... My first guess was that the browser finished his launching before the Kindle.
you can try to use a pause function (sleep) on the script.
thomass is offline   Reply With Quote
Old 05-25-2013, 08:15 AM   #12
Vava
Member
Vava began at the beginning.
 
Posts: 17
Karma: 10
Join Date: May 2013
Device: PaperWhite
I did but it seems that the browser begin his launching anyway, then the function sleep hold and at the end the menu shows up. (I place the sleep function before my call to the browser)
Vava is offline   Reply With Quote
Old 06-02-2013, 07:20 AM   #13
Vava
Member
Vava began at the beginning.
 
Posts: 17
Karma: 10
Join Date: May 2013
Device: PaperWhite
Hi ! I would use the event handler to switch from normal mode to standby mode, standby mode to normal mode, etc ... But the script in the folder "suspend" only partially executed and I do not get out of standby mode. Any ideas?

Here are the contents of my scripts.
"resume":
Code:
#!/bin/sh

echo >> /mnt/us/scripts/logs.txt

date >> /mnt/us/scripts/logs.txt
echo Kindle awakes >> /mnt/us/scripts/logs.txt

date >> /mnt/us/scripts/logs.txt
# enable WiFi
echo enable WiFi : >> /mnt/us/scripts/logs.txt
lipc-set-prop com.lab126.cmd wirelessEnable 1
lipc-get-prop com.lab126.cmd wirelessEnable >> /mnt/us/scripts/logs.txt
# sleep
echo sleep during 10 secondes >> /mnt/us/scripts/logs.txt
sleep 10

date >> /mnt/us/scripts/logs.txt
# calendar update
echo calendar update >> /mnt/us/scripts/logs.txt
/mnt/us/extensions/WebLaunch/bin/start.sh &

date >> /mnt/us/scripts/logs.txt
# delay nedeed to do the update
echo sleep during 10 secondes >> /mnt/us/scripts/logs.txt
sleep 10

date >> /mnt/us/scripts/logs.txt
# disable WiFi
echo disable WiFi >> /mnt/us/scripts/logs.txt
lipc-set-prop com.lab126.cmd wirelessEnable 0
lipc-get-prop com.lab126.cmd wirelessEnable >> /mnt/us/scripts/logs.txt

# sleep
echo sleep during 1 secondes >> /mnt/us/scripts/logs.txt
sleep 1

date >> /mnt/us/scripts/logs.txt
# go to screenSaver mode (even if the screen doesn't change)
echo go to screenSaver mode >> /mnt/us/scripts/logs.txt
lipc-set-prop com.lab126.powerd powerButton 0
"suspend":
Code:
#!/bin/sh

echo >> /mnt/us/scripts/logs.txt

date >> /mnt/us/scripts/logs.txt
echo Kindle falls asleep >> /mnt/us/scripts/logs.txt

date >> /mnt/us/scripts/logs.txt
# EXECUTION STOPS HERE
# synchro each hour
echo Kindle pending awakening (during 1 hour) >> /mnt/us/scripts/logs.txt
# sleep 3600
sleep 10

# awakening
date >> /mnt/us/scripts/logs.txt
# out of screenSaver mode
echo out of screenSaver mode >> /mnt/us/scripts/logs.txt
lipc-set-prop com.lab126.powerd powerButton 0
Vava is offline   Reply With Quote
Old 06-02-2013, 07:59 AM   #14
knc1
Embedded Cheerleader
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 6,226
Karma: 5830430
Join Date: Feb 2012
Device: Too many.
Short answer: PEBCAK

Longer answer (but not all inclusive):

1) "sleep" is a shell command, not a system command.
It only effects the execution path of the script that contains it.

2) Where / How are these scripts being called?

3) If you do succeed in putting the processor to sleep, then you need a hardware event from some hardware that is still running to wake it.

4) Writing less than a full erase block of data to flash will cause the "short write" to be cached (somewhere, there are several places) in the system or within the flash chip's controller itself.

Shutting down the power to the flash and its internal controller before it completes one of its erase and re-program functions (while the operation is in progress) will at best result in a corrupted, non-recoverable, erase (storage) block in the flash. At worse, a corrupted, non-recoverable internal control structure (then it is unsolder flash chip, solder in a new one time).

You really should try to understand the system and its hardware before trying to take control of it outside of its normal dependence system.

PS: You are in the wrong thread.
This thread is about responding to system events, not about trying to manufacture them.
If you can't find a thread about your subject here, start your own, they are cheap here.

Last edited by knc1; 06-02-2013 at 08:02 AM.
knc1 is offline   Reply With Quote
Old 06-02-2013, 09:42 AM   #15
Vava
Member
Vava began at the beginning.
 
Posts: 17
Karma: 10
Join Date: May 2013
Device: PaperWhite
1) Yes, and that's how I want to use it

2) These scripts are called by the eventHandler (that's why I posted a reply instead of create a new thread)

3) Ok, that's what I would like to know. That means there is no chance I succeed to came back from standby mode without an external intervention ?

4) I do not see why it's dangerous. I thought that I was only sending the same command that the system send by pressing the physical button.
Vava is offline   Reply With Quote
Reply

Tags
events, k5 tools, kindle, kite, screensaver

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
K5 is it possible to run k5 launchpad scripts on k5 techiemonkey Kindle Developer's Corner 3 07-30-2012 09:10 AM
Kite on K3G launches scripts randomly on boot or unplug jmseight Kindle Developer's Corner 0 03-23-2012 01:55 PM
Kindle tries to run C/++ applications like sh scripts? dnR Kindle Developer's Corner 1 01-09-2011 07:45 AM


All times are GMT -4. The time now is 01:58 AM.


MobileRead.com is a privately owned, operated and funded community.