Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 04-24-2025, 08:13 AM   #1
hanginwithdaddo
Enthusiast
hanginwithdaddo doesn't litterhanginwithdaddo doesn't litter
 
hanginwithdaddo's Avatar
 
Posts: 27
Karma: 122
Join Date: Apr 2025
Location: Pennsylvania, USA
Device: Kindle Signature, 12th Gen.
How to listen for most events dispatched by a Kindle

All, you can use the script below to listen for and display most events dispatched by a given kindle OS. Just invoke it and then perform various actions, such as pressing the power button, to see the events dispatched in response to the given action based on the current state of the kindle. Press ctrl-C to exit.

Code:
#!/bin/bash
#
# Listen for and display most events generated by a given kindle.
cd /usr/share/webkit-1.0/pillow/javascripts
sources=$(grep "const .*_SOURCE = \"com\." * | sed -e 's/.*_SOURCE = "\(.*\)".*/\1/')
echo "${sources}" | sort -u | lipc-wait-event -l -m "*" | while read event
do
	echo "${event}"
done
Example from pressing the power button twice, starting with the Kindle not in screen saver mode. Note that lipc-wait-event won't display anything until it receives and event. This example was from a Kindle Signature running OS version 5.17.0.

Code:
[root@kindle bin]# ./eventlistener.sh
Event Source: com.lab126.appmgrd
Event Source: com.lab126.asr
Event Source: com.lab126.audiomgrd
Event Source: com.lab126.btfd
Event Source: com.lab126.pillow
Event Source: com.lab126.powerd
Event Source: com.lab126.system
Event Source: com.lab126.winmgr
Waiting for events...
com.lab126.powerd goingToScreenSaver 2
com.lab126.winmgr titleBarVisiblityChange "invisible"
com.lab126.powerd t1TimerReset
com.lab126.powerd outOfScreenSaver 1
com.lab126.winmgr titleBarVisiblityChange "visible"
com.lab126.powerd exitingScreenSaver
I used this silly script to see if there were any events that I could catch to know if the kindle is connected to a power source and to identify events related to the kindle disconnecting from a given USB device. Hope someone finds this useful. Just another tool for our developer toolkit.
hanginwithdaddo is offline   Reply With Quote
Old 04-24-2025, 11:40 AM   #2
mergen3107
Wizard
mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.
 
mergen3107's Avatar
 
Posts: 1,497
Karma: 5000046
Join Date: Feb 2012
Location: Cape Canaveral
Device: Kindle Scribe
Cool! Do you know if the script can catch when Kindle transitions from regular sleep to deep sleep?
mergen3107 is offline   Reply With Quote
Old 04-24-2025, 02:47 PM   #3
hanginwithdaddo
Enthusiast
hanginwithdaddo doesn't litterhanginwithdaddo doesn't litter
 
hanginwithdaddo's Avatar
 
Posts: 27
Karma: 122
Join Date: Apr 2025
Location: Pennsylvania, USA
Device: Kindle Signature, 12th Gen.
Yes, you will see a powerd "readyToSuspend" event as it's about to go into deep sleep and a "suspending" event as it goes into deep sleep (meaning things like cron activities won't run). I'm in the process of reworking a script that I have for preventing the device from going into a deep sleep when connected to a power source which I'll post in another thread eventually. I use my kindle to control my home automation and when it's plugged in I don't want it going into a deep sleep. I also use the script to support rotating screen images every 5 minutes via cron and sounding a grandather clock sounds at appropriate times, all of which I only want running when plugged into a power source. Enjoy!

Last edited by hanginwithdaddo; 04-24-2025 at 03:01 PM. Reason: corrected typo
hanginwithdaddo is offline   Reply With Quote
Old 04-24-2025, 04:44 PM   #4
crazyelectron
Junior Member
crazyelectron doesn't littercrazyelectron doesn't littercrazyelectron doesn't litter
 
crazyelectron's Avatar
 
Posts: 3
Karma: 210
Join Date: Nov 2023
Device: PW5 * 2, KS 2022
Great! There are quite a few more event sources we can eavesdrop:

Code:
lipc-probe -l
and also

Code:
grep -sori "com\.lab126\.[a-z\.]\+" /etc /usr | cut -d ':' -f 2 | sort -u
(this one takes a while)
crazyelectron is offline   Reply With Quote
Old 04-25-2025, 01:38 AM   #5
mergen3107
Wizard
mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.
 
mergen3107's Avatar
 
Posts: 1,497
Karma: 5000046
Join Date: Feb 2012
Location: Cape Canaveral
Device: Kindle Scribe
Awesome! Thanks!
I am currently looking into an issue where KOReader’s toggle for hall effect sensor (cover magnet) doesn’t work when Kindle is in suspend.

I am looking into ways to trigger the suspend manually.

Do you think there is lipc-property for this?
mergen3107 is offline   Reply With Quote
Old 04-25-2025, 07:19 AM   #6
Marek
Groupie
Marek ought to be getting tired of karma fortunes by now.Marek ought to be getting tired of karma fortunes by now.Marek ought to be getting tired of karma fortunes by now.Marek ought to be getting tired of karma fortunes by now.Marek ought to be getting tired of karma fortunes by now.Marek ought to be getting tired of karma fortunes by now.Marek ought to be getting tired of karma fortunes by now.Marek ought to be getting tired of karma fortunes by now.Marek ought to be getting tired of karma fortunes by now.Marek ought to be getting tired of karma fortunes by now.Marek ought to be getting tired of karma fortunes by now.
 
Marek's Avatar
 
Posts: 187
Karma: 1512344
Join Date: Jul 2023
Device: PW3, PW4 :(, KT5, PW5, KLC
Just to throw my two cents in

Here's a (imo) more readable nicer view of the lipc-probe https://gist.github.com/notmarek/4fd...0110c926067c88 it also has the queryable Hash properties that you dont get with normal lipc-probe, as for the events you can use dbus-monitor to monitor all the lipc traffic.
Marek is offline   Reply With Quote
Old 04-25-2025, 08:23 AM   #7
hanginwithdaddo
Enthusiast
hanginwithdaddo doesn't litterhanginwithdaddo doesn't litter
 
hanginwithdaddo's Avatar
 
Posts: 27
Karma: 122
Join Date: Apr 2025
Location: Pennsylvania, USA
Device: Kindle Signature, 12th Gen.
Quote:
Originally Posted by crazyelectron View Post
Great! There are quite a few more event sources we can eavesdrop:

Code:
lipc-probe -l
and also

Code:
grep -sori "com\.lab126\.[a-z\.]\+" /etc /usr | cut -d ':' -f 2 | sort -u
(this one takes a while)
Just a note that properties reported by lipc-probe are *properties* that you can set and query, using lipc-set-prop and lipc-get-prop, not events that you can wait on.

Last edited by hanginwithdaddo; 04-25-2025 at 08:41 AM. Reason: corrected typo
hanginwithdaddo is offline   Reply With Quote
Old 04-25-2025, 08:34 AM   #8
hanginwithdaddo
Enthusiast
hanginwithdaddo doesn't litterhanginwithdaddo doesn't litter
 
hanginwithdaddo's Avatar
 
Posts: 27
Karma: 122
Join Date: Apr 2025
Location: Pennsylvania, USA
Device: Kindle Signature, 12th Gen.
Quote:
Originally Posted by mergen3107 View Post
Awesome! Thanks!
I am currently looking into an issue where KOReader’s toggle for hall effect sensor (cover magnet) doesn’t work when Kindle is in suspend.

I am looking into ways to trigger the suspend manually.

Do you think there is lipc-property for this?
I don't see a property in "lipc-probe -a -v" output that would trigger a suspend. Realize that when the kindle goes into its "suspended" state, nothing runs (e.g., no cron jobs run, etc.). Once it goes into the suspend state the only way out of it, I believe, is to press the power button to wake up the device. You wouldn't be able to wake it up programmatically. If in "screen saver mode", however, you can "wake up" the device using the following:

Code:
lipc-set-prop com.lab126.powerd wakeUp 1
hanginwithdaddo is offline   Reply With Quote
Old 04-25-2025, 09:30 AM   #9
mergen3107
Wizard
mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.
 
mergen3107's Avatar
 
Posts: 1,497
Karma: 5000046
Join Date: Feb 2012
Location: Cape Canaveral
Device: Kindle Scribe
Thanks! Over on KOReader Github we found that another way out from suspend is using the magnet cover! We are trying to tame it now, so that it stays off when KOReader turns it off.
https://github.com/koreader/koreader...ent-2822591700
mergen3107 is offline   Reply With Quote
Old 04-25-2025, 09:52 AM   #10
hanginwithdaddo
Enthusiast
hanginwithdaddo doesn't litterhanginwithdaddo doesn't litter
 
hanginwithdaddo's Avatar
 
Posts: 27
Karma: 122
Join Date: Apr 2025
Location: Pennsylvania, USA
Device: Kindle Signature, 12th Gen.
Quote:
Originally Posted by mergen3107 View Post
Thanks! Over on KOReader Github we found that another way out from suspend is using the magnet cover! We are trying to tame it now, so that it stays off when KOReader turns it off.
https://github.com/koreader/koreader...ent-2822591700
Something you *might* be able to do is to minimize the suspend grace period and request that the kindle go into screen saver mode using something like:

Code:
lipc-set-prop suspendGrace 0
lipc-set-prop powerButton 1
I haven't tried this though. If the above works, the kindle should go into screen saver mode and then immediately suspend. If the grace of 0 doesn't work try 1. These units are usually in seconds, from what I've experienced.
hanginwithdaddo is offline   Reply With Quote
Old 04-25-2025, 07:35 PM   #11
mergen3107
Wizard
mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.mergen3107 ought to be getting tired of karma fortunes by now.
 
mergen3107's Avatar
 
Posts: 1,497
Karma: 5000046
Join Date: Feb 2012
Location: Cape Canaveral
Device: Kindle Scribe
So, it will always directly go to suspend after power button?
I am also trying to prevent my favorite foot-gun situations when it keeps locking so fast I can’t have enough time to revert it
mergen3107 is offline   Reply With Quote
Old 04-25-2025, 08:35 PM   #12
hanginwithdaddo
Enthusiast
hanginwithdaddo doesn't litterhanginwithdaddo doesn't litter
 
hanginwithdaddo's Avatar
 
Posts: 27
Karma: 122
Join Date: Apr 2025
Location: Pennsylvania, USA
Device: Kindle Signature, 12th Gen.
deleted.

Last edited by hanginwithdaddo; 04-25-2025 at 08:41 PM.
hanginwithdaddo is offline   Reply With Quote
Old 04-25-2025, 08:38 PM   #13
hanginwithdaddo
Enthusiast
hanginwithdaddo doesn't litterhanginwithdaddo doesn't litter
 
hanginwithdaddo's Avatar
 
Posts: 27
Karma: 122
Join Date: Apr 2025
Location: Pennsylvania, USA
Device: Kindle Signature, 12th Gen.
Quote:
Originally Posted by mergen3107 View Post
So, it will always directly go to suspend after power button?
I am also trying to prevent my favorite foot-gun situations when it keeps locking so fast I can’t have enough time to revert it
Based on my testing, the kindle will suspend after 60 seconds of being in screen saver mode, even if plugged into a power source. This is on my Kindle Signature 12th Gen. This is one of the reasons I had to write my own event processing script to prevent the kindle form suspending when plugged into a power source. On my Kindle Touch, the kindle did not suspend when plugged into a power source.

I'm just about ready to publish what I've done so others can look at it and reuse anything they find useful.
hanginwithdaddo is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Detecting headphone events on kindle touch inuxy Kindle Developer's Corner 4 07-15-2012 11:38 AM
Free (Kindle) Reconstructing 3/11: Earthquake, Tsunami... [Japan Recent Events] ATDrake Deals and Resources (No Self-Promotion or Affiliate Links) 0 06-11-2012 03:54 PM
Free Book (Kindle/Nook/Sony) - Listen koland Deals and Resources (No Self-Promotion or Affiliate Links) 7 01-31-2011 08:18 PM
Do you listen to music on the kindle while reading? demoric Amazon Kindle 7 07-24-2009 10:33 AM


All times are GMT -4. The time now is 08:04 PM.


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