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 10-25-2013, 02:56 AM   #1
Aeris
Developer's Corner Mascot
Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.
 
Aeris's Avatar
 
Posts: 486
Karma: 1277790
Join Date: Sep 2013
Device: Kindle Paperwhite 5.3.4, Kindle Keyboard 3.4
Lightbulb Simple way for exiting programs with power button without showing the screensaver

On some KUAL apps (like "draw"), physical power button has been used on KindleTouch and PW to execute some commands, like exiting the program. This was a bit annoying, because put the device into screensaver mode and user had to wake up the device later, by hand. To avoid this, just add to dbus-monitor event commands this one:

Code:
lipc-set-prop com.lab126.powerd powerButton 1
Screensaver won't show and user won't have to manually wake up the device. He will see only the light flashing on PW, for a minimal amount of time (maybe also this can be fixed, but is quite good as visual feedback too).

Sample KUAL app attached ("draw", renamed to "whiteboard" for the occasion)

App script:
Code:
#!/bin/sh
SSSTATE=`lipc-get-prop com.lab126.powerd preventScreenSaver`
lipc-set-prop com.lab126.powerd preventScreenSaver 0
/usr/bin/xtestlab126 &
( dbus-monitor "interface='com.lab126.powerd',member='goingToScreenSaver'" --system; killall xtestlab126; lipc-set-prop com.lab126.powerd powerButton 1; lipc-set-prop com.lab126.powerd preventScreenSaver "$SSSTATE" ) &
usleep 50000
killall -INT dbus-monitor
General approach:
Code:
( dbus-monitor "interface='com.lab126.interfaceName',member='interfaceEvent'" --system;  lipc-set-prop com.lab126.powerd powerButton 1; yourCommandsHere) &
Attached Files
File Type: zip whiteboard.zip (1.3 KB, 131 views)

Last edited by Aeris; 10-25-2013 at 06:32 PM. Reason: Updated to prevent screensaver
Aeris is offline   Reply With Quote
Old 10-25-2013, 03:06 AM   #2
brianinmaine
Evangelist
brianinmaine ought to be getting tired of karma fortunes by now.brianinmaine ought to be getting tired of karma fortunes by now.brianinmaine ought to be getting tired of karma fortunes by now.brianinmaine ought to be getting tired of karma fortunes by now.brianinmaine ought to be getting tired of karma fortunes by now.brianinmaine ought to be getting tired of karma fortunes by now.brianinmaine ought to be getting tired of karma fortunes by now.brianinmaine ought to be getting tired of karma fortunes by now.brianinmaine ought to be getting tired of karma fortunes by now.brianinmaine ought to be getting tired of karma fortunes by now.brianinmaine ought to be getting tired of karma fortunes by now.
 
brianinmaine's Avatar
 
Posts: 456
Karma: 1287375
Join Date: Jan 2013
Location: West Gardiner, Maine
Device: Touch (5.3.7)
nice! that always bugged me also. I'll try it on my touch when I can.
brianinmaine is offline   Reply With Quote
Old 10-25-2013, 08:08 AM   #3
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,586
Karma: 6299991
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
This is nice.

How would you solve the additional puzzle of the "screensaver time issue."

When people choose to run an app with this configuration of "tap-out" escape, the default screensaver timeout time of 600 seconds comes back into play.

as you yourself have noted, some applications don't like being "backgrounded" by the Screensaver layer and will in fact end up irretrievably hidden...

There is a way to touch the screensaver timeout and set it back to another ten minutes, perhaps that could be part of the solution.

Code:
lipc-set-prop com.lab126.powerd -i touchScreenSaverTimeout 1


One final question, I wonder if the lipc-wait-event construct would be worth demonstrating too...

Last edited by twobob; 10-25-2013 at 08:24 AM.
twobob is offline   Reply With Quote
Old 10-25-2013, 08:21 AM   #4
Aeris
Developer's Corner Mascot
Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.
 
Aeris's Avatar
 
Posts: 486
Karma: 1277790
Join Date: Sep 2013
Device: Kindle Paperwhite 5.3.4, Kindle Keyboard 3.4
Quote:
Originally Posted by twobob View Post
How would you solve the puzzle of the screensaver time issue.
Do you mean the issue regarding screensaver after the 10 minutes timeout? A simple workaround could be to temporary increase the time needed to enter screensaver to something huge (maybe lipc-set-prop com.lab126.powerd touchScreenSaverTimeout could do the work). Or to send periodically a wakeup signal (lipc-set-prop com.lab126.powerd wakeUp 1 about every 9 minutes). Or again, prevent screensaver and listen on powerButton events (if exist). This would be the best solution because allow auto-screensaver while keeping the power button usable to quit the app

Last edited by Aeris; 10-25-2013 at 08:26 AM.
Aeris is offline   Reply With Quote
Old 10-25-2013, 08:25 AM   #5
Aeris
Developer's Corner Mascot
Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.
 
Aeris's Avatar
 
Posts: 486
Karma: 1277790
Join Date: Sep 2013
Device: Kindle Paperwhite 5.3.4, Kindle Keyboard 3.4
Sorry, I read late your edit... and wrote powerButton instead of wakeUp, now fixed
Aeris is offline   Reply With Quote
Old 10-25-2013, 08:26 AM   #6
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,586
Karma: 6299991
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
right. I was busily typing a better question.

I guess I was asking /how/ that 590s loop might be best constructed in your opinion, in the context of this example.

EDIT: I have considered this problem myself before and didn't come up with a really tidy solution, hence me asking.

Last edited by twobob; 10-25-2013 at 08:31 AM.
twobob is offline   Reply With Quote
Old 10-25-2013, 08:29 AM   #7
Aeris
Developer's Corner Mascot
Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.
 
Aeris's Avatar
 
Posts: 486
Karma: 1277790
Join Date: Sep 2013
Device: Kindle Paperwhite 5.3.4, Kindle Keyboard 3.4
Forking the bash script on two thread... I mean, launch a second .sh from the main script, with a while cycle within, then running the dbus-monitoring code line without having to wait the forked code to quit... after the program exits the second script will be killed too with a simple killall command

EDIT: don't know why but lipc-set-prop com.lab126.powerd wakeUp 1 doesn't seem to work O.o I'd better try your one

Last edited by Aeris; 10-25-2013 at 08:50 AM.
Aeris is offline   Reply With Quote
Old 10-25-2013, 09:00 AM   #8
Aeris
Developer's Corner Mascot
Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.
 
Aeris's Avatar
 
Posts: 486
Karma: 1277790
Join Date: Sep 2013
Device: Kindle Paperwhite 5.3.4, Kindle Keyboard 3.4
Proof of concept
(I can't test this until I'm back home)

- File removed, fixed and placed in the first post --
Attached Files
File Type: zip whiteboard.zip (1.3 KB, 128 views)

Last edited by Aeris; 10-25-2013 at 06:31 PM.
Aeris is offline   Reply With Quote
Old 10-25-2013, 09:05 AM   #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,586
Karma: 6299991
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
Dont let me bother you while you are busy. Thanks for the test. I will abuse it.
twobob is offline   Reply With Quote
Old 10-25-2013, 09:11 AM   #10
Aeris
Developer's Corner Mascot
Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.
 
Aeris's Avatar
 
Posts: 486
Karma: 1277790
Join Date: Sep 2013
Device: Kindle Paperwhite 5.3.4, Kindle Keyboard 3.4
No bothering just going to uni now... anyway, doesn't works. Dunno why
Aeris is offline   Reply With Quote
Old 10-25-2013, 09:17 AM   #11
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,586
Karma: 6299991
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
Another puzzle to be solved
twobob is offline   Reply With Quote
Old 10-25-2013, 06:21 PM   #12
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,586
Karma: 6299991
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
Code:
#!/bin/sh
SSSTATE=`lipc-get-prop com.lab126.powerd preventScreenSaver`
lipc-set-prop com.lab126.powerd preventScreenSaver 0
/mnt/us/extensions/whiteboard/bin/wakeup.sh &
/usr/bin/xtestlab126 &
( dbus-monitor "interface='com.lab126.powerd',member='goingToScreenSaver'" --system;  killall xtestlab126; lipc-set-prop com.lab126.powerd powerButton 1; lipc-set-prop com.lab126.powerd preventScreenSaver "$SSSTATE" ) &
usleep 50000
killall -INT dbus-monitor
killall wakeup.sh

should be


Code:
#!/bin/sh
SSSTATE=`lipc-get-prop com.lab126.powerd preventScreenSaver`
lipc-set-prop com.lab126.powerd preventScreenSaver 0
/mnt/us/extensions/whiteboard/bin/wakeup.sh &
/usr/bin/xtestlab126 &
( dbus-monitor "interface='com.lab126.powerd',member='goingToScreenSaver'" --system;  killall wakeup.sh; killall xtestlab126; lipc-set-prop com.lab126.powerd powerButton 1; lipc-set-prop com.lab126.powerd preventScreenSaver "$SSSTATE" ) &
usleep 50000
killall -INT dbus-monitor
twobob is offline   Reply With Quote
Old 10-25-2013, 06:27 PM   #13
Aeris
Developer's Corner Mascot
Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.
 
Aeris's Avatar
 
Posts: 486
Karma: 1277790
Join Date: Sep 2013
Device: Kindle Paperwhite 5.3.4, Kindle Keyboard 3.4
Thank you!! Updating package in the first post PS I've spent several hours to find a way to monitor the powerButton event but nothing... (I don't love while cicles xD)

Last edited by Aeris; 10-25-2013 at 06:33 PM.
Aeris is offline   Reply With Quote
Old 10-26-2013, 08:15 AM   #14
Aeris
Developer's Corner Mascot
Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.Aeris ought to be getting tired of karma fortunes by now.
 
Aeris's Avatar
 
Posts: 486
Karma: 1277790
Join Date: Sep 2013
Device: Kindle Paperwhite 5.3.4, Kindle Keyboard 3.4
Does anybody know how much resources does sleep function consume (CPU and RAM mainly)? I've googled but didn't find nothing... are so low to be completely neglectable?

Last edited by Aeris; 10-26-2013 at 08:48 AM.
Aeris is offline   Reply With Quote
Old 10-26-2013, 09:46 AM   #15
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,586
Karma: 6299991
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
from what I can figure the process is put into a "sleep" state (see htop, the processes marked S are sleeping) and then (depending if the usleep or sleep command) is used they are subsequently triggered by a "type of" signal. (this /may/ be the "alarm" signal)

I am also relatively certain this is achieved by the use of http://man7.org/linux/man-pages/man2...meofday.2.html mixed with http://man7.org/linux/man-pages/man2/alarm.2.html , but as I intimated above usleep is guaranteed to fire - whereas "sleep" is a bit more sketchy

strace usage often reveals MANY gettimeofday calls inside apps, and I have always thought that this was /probably/ related to sleeping processes.

In terms of resource I would list it as "negligible"

Hopefully someone can back-up or pooh-pooh what I have said here as it is mainly conjecture.

Last edited by twobob; 10-29-2013 at 03:20 AM.
twobob is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PRS-505 Power button not shutting off Atagahi Sony Reader 2 11-16-2012 05:48 PM
PRS-T1 How can I use back button as power button? younghere Sony Reader 1 03-12-2012 06:37 PM
PRS-T1 Does Screensaver use power or not ? blupaul Sony Reader 13 11-06-2011 04:59 AM
Dead K3 showing a non-OEM screensaver Francesco Amazon Kindle 5 07-10-2011 11:57 PM
Keylock keeping current page - not showing screensaver? guiyoforward Amazon Kindle 8 10-13-2010 06:44 PM


All times are GMT -4. The time now is 12:41 PM.


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