|  12-24-2011, 04:10 AM | #1 | 
| Groupie            Posts: 159 Karma: 20390 Join Date: Feb 2009 Device: none | 
				
				Change Screensaver Timeout (how long before sleeps)
			 
			
			These are simple Launchpad scripts which change when the Kindle goes to sleep and the screensaver on the Kindle starts. The default is '10 mins'.  Here are my scripts. I actually have several set to Launchpad shortcuts, from 15 minutes to 120 minutes: screensaver_timeout.ini Code: [Actions] ; Screensaver Timeout S A = !source /mnt/us/launchpad/screensaver_timeout_15.sh S B = !source /mnt/us/launchpad/screensaver_timeout_20.sh S C = !source /mnt/us/launchpad/screensaver_timeout_30.sh S D = !source /mnt/us/launchpad/screensaver_timeout_45.sh S E = !source /mnt/us/launchpad/screensaver_timeout_60.sh S F = !source /mnt/us/launchpad/screensaver_timeout_90.sh S G = !source /mnt/us/launchpad/screensaver_timeout_120.sh S X = !source /mnt/us/launchpad/screensaver_timeout_reset.sh Code: #!/bin/sh
mntroot rw
# Based on version 0.01 (20090724) ebs
V="0.02.N"
# Default timeout in seconds
TIMEOUT=900
# Log somewhere out of the way
mkdir /mnt/us/sstimeout
L=/mnt/us/sstimeout/screensaver-timeout_install.log
# Result codes
OK=0
ERR=1
echo >> ${L}
echo "install: screensaver-timeout v${V}, $(date)" >> ${L}
# Give user a way to override timeout
U=/mnt/us/screensaver-timeout
if [ -f ${U} ] ; then
T=$(head -n 1 ${U} | sed 's/[^0-9]//g')
if [ "${T}" -gt 59 ] ; then
echo "Using user specified timeout ${T} from ${U}" >> ${L}
TIMEOUT=${T}
fi
fi
# FW 3.X
# if [ -f /etc/kdb/system/daemon/powerd/t1_timeout ] ; then
# F=/etc/kdb/system/daemon/powerd/t1_timeout
# FW 3.3
if [ -f /etc/kdb.src/luigi/system/daemon/powerd/t1_timeout ] ; then
F=/etc/kdb.src/luigi/system/daemon/powerd/t1_timeout
# Make a backup just in case
[ -f /mnt/us/sstimeout/t1_timeout ] || cp -p ${F} /mnt/us/sstimeout/t1_timeout 2>> ${L} || exit ${ERR}
OT=$(tail -n 1 ${F})
if [ -n "${OT}" ] ; then
if [ "${OT}" != "${TIMEOUT}" ] ; then
echo "Replacing sleep timeout (${OT} -> ${TIMEOUT})" >> ${L}
(echo -en "RG002\n40\n<DATA>\n${TIMEOUT}" > ${F}) 2>> ${L} || exit ${ERR}
else
echo "Timeout is already set to ${TIMEOUT}, skipping..." >> ${L}
fi
else
echo "Couldn't find current timeout, aborting" >> ${L}
exit ${ERR}
fi
else
# FW 2.X
F=/etc/powerd.conf
# Make a backup just in case
[ -f /mnt/us/sstimeout/powerd.conf ] || cp -p ${F} /mnt/us/sstimeout/powerd.conf 2>> ${L} || exit ${ERR}
K="t1_timeout:"
OT=$(grep "^${K}" ${F} | cut -b 13-)
if [ -n "${OT}" ] ; then
if [ "${OT}" != "${TIMEOUT}" ] ; then
echo "Replacing sleep timeout (${OT} -> ${TIMEOUT})" >> ${L}
sed -i -e "s/^\(${K}\).*$/\1 ${TIMEOUT}/" ${F} 2>> ${L} || exit ${ERR}
else
echo "Timeout is already set to ${TIMEOUT}, skipping..." >> ${L}
fi
else
echo "Addding sleep timeout (${TIMEOUT})" >> ${L}
(echo "${K} ${TIMEOUT}" >> ${F}) 2>> ${L} || exit ${ERR}
fi
fi
echo "Done!" >> ${L}
/etc/init.d/powerd restart
mntroot ro
exit ${OK}Code: #!/bin/sh
mntroot rw
# Based on version 0.01 (20090724) ebs
V="0.02.N"
# Default timeout in seconds
TIMEOUT=600
# Log somewhere out of the way
mkdir /mnt/us/sstimeout
L=/mnt/us/sstimeout/screensaver-timeout_install.log
# Result codes
OK=0
ERR=1
echo >> ${L}
echo "install: screensaver-timeout v${V}, $(date)" >> ${L}
# Give user a way to override timeout
U=/mnt/us/screensaver-timeout
if [ -f ${U} ] ; then
T=$(head -n 1 ${U} | sed 's/[^0-9]//g')
if [ "${T}" -gt 59 ] ; then
echo "Using user specified timeout ${T} from ${U}" >> ${L}
TIMEOUT=${T}
fi
fi
# FW 3.X
# if [ -f /etc/kdb/system/daemon/powerd/t1_timeout ] ; then
# F=/etc/kdb/system/daemon/powerd/t1_timeout
# FW 3.3
if [ -f /etc/kdb.src/luigi/system/daemon/powerd/t1_timeout ] ; then
F=/etc/kdb.src/luigi/system/daemon/powerd/t1_timeout
# Make a backup just in case
[ -f /mnt/us/sstimeout/t1_timeout ] || cp -p ${F} /mnt/us/sstimeout/t1_timeout 2>> ${L} || exit ${ERR}
OT=$(tail -n 1 ${F})
if [ -n "${OT}" ] ; then
if [ "${OT}" != "${TIMEOUT}" ] ; then
echo "Replacing sleep timeout (${OT} -> ${TIMEOUT})" >> ${L}
(echo -en "RG002\n40\n<DATA>\n${TIMEOUT}" > ${F}) 2>> ${L} || exit ${ERR}
else
echo "Timeout is already set to ${TIMEOUT}, skipping..." >> ${L}
fi
else
echo "Couldn't find current timeout, aborting" >> ${L}
exit ${ERR}
fi
else
# FW 2.X
F=/etc/powerd.conf
# Make a backup just in case
[ -f /mnt/us/sstimeout/powerd.conf ] || cp -p ${F} /mnt/us/sstimeout/powerd.conf 2>> ${L} || exit ${ERR}
K="t1_timeout:"
OT=$(grep "^${K}" ${F} | cut -b 13-)
if [ -n "${OT}" ] ; then
if [ "${OT}" != "${TIMEOUT}" ] ; then
echo "Replacing sleep timeout (${OT} -> ${TIMEOUT})" >> ${L}
sed -i -e "s/^\(${K}\).*$/\1 ${TIMEOUT}/" ${F} 2>> ${L} || exit ${ERR}
else
echo "Timeout is already set to ${TIMEOUT}, skipping..." >> ${L}
fi
else
echo "Addding sleep timeout (${TIMEOUT})" >> ${L}
(echo "${K} ${TIMEOUT}" >> ${F}) 2>> ${L} || exit ${ERR}
fi
fi
echo "Done!" >> ${L}
/etc/init.d/powerd restart
mntroot ro
exit ${OK}I used the code by pilotdrh2003, found here: https://www.mobileread.com/forums/sho...postcount=1210, and, thanks to WS64, I altered it a small bit (so it goes to the appropriate directory on firmware 3.3 (uncomment the 3.X and comment the 3.3 section if required). Here, there are Launchpad shortcuts you can use to do it. Easy peasy. So far so good. If you have any problems, feel free to share. Note: if you have a /mnt/us/screensaver-timeout file with a custom screensaver timeout (in seconds), it will override whatever Launchpad shortcut time you use when you run one of the shortcuts. Last edited by inameiname; 04-16-2012 at 09:42 PM. Reason: Edited to show it seems to be fully-working now, rather than merely in the testing phase | 
|   |   | 
|  12-24-2011, 07:10 AM | #2 | 
| (offline)            Posts: 2,907 Karma: 6736094 Join Date: Dec 2011 Device: K3, K4, K5, KPW, KPW2 | 
			
			Just guessing around... If it's really the sed command failing (for whichever reason), try this instead of copying and then editing in place. Code: sed -e 's/600/900/' /etc/kdb.src/luigi/system/daemon/powerd/t1_timeout.bkp > /etc/kdb.src/luigi/system/daemon/powerd/t1_timeout | 
|   |   | 
|  12-24-2011, 11:16 AM | #3 | |
| Groupie            Posts: 159 Karma: 20390 Join Date: Feb 2009 Device: none | Quote: 
 I didn't try "sed -i -e 's/.../'" yet. What would that do, and how would I write it in this case? | |
|   |   | 
|  12-24-2011, 11:34 AM | #4 | |
| (offline)            Posts: 2,907 Karma: 6736094 Join Date: Dec 2011 Device: K3, K4, K5, KPW, KPW2 | Quote: 
 Anyway, I just ran this on the device, and sed is working as it should. Code: [root@kindle tmp]# echo 12345600789 > test.txt [root@kindle tmp]# sed -e 's/600/900/' test.txt 12345900789 I would suggest to rewrite the thing to a simpler and "less dangerous" variant, something like: Code: if [ -f /etc/kdb.src/luigi/system/daemon/powerd/t1_timeout.TEMPLATE ] then sed -e 's/_TIMEOUT_/900/' /etc/kdb.src/luigi/system/daemon/powerd/t1_timeout.TEMPLATE > /etc/kdb.src/luigi/system/daemon/powerd/t1_timeout /etc/init.d/powerd restart fi exit | |
|   |   | 
|  12-24-2011, 12:05 PM | #5 | |
| Groupie            Posts: 159 Karma: 20390 Join Date: Feb 2009 Device: none | Quote: 
 Fortunately, I did figure out another way to do this. I will show you what I did in the next post. BTW, I think not having 'mntroot rw' and 'mntroot ro' in the script was the issue. I say this only because that is what resolved the 'failure' message I kept getting with the updated script. Last edited by inameiname; 12-24-2011 at 12:16 PM. | |
|   |   | 
|  12-24-2011, 12:10 PM | #6 | 
| Groupie            Posts: 159 Karma: 20390 Join Date: Feb 2009 Device: none | 
			
			So I think I figured out how to do this. Using the code by pilotdrh2003, found here: https://www.mobileread.com/forums/sho...postcount=1210, thanks to WS64, I altered it a small bit (so it goes to the appropriate directory on firmware 3.3 (uncomment the 3.X and comment the 3.3 section if required). Here, there are Launchpad shortcuts you can use to do it. Easy peasy. Please test to verify that it works. FYI, one other customization is that it is set on the 'us' directory. So change if needed. The fix is already included above, in the first post. Note: if you have a /mnt/us/screensaver-timeout file with a custom screensaver timeout (in seconds), it will override whatever Launchpad shortcut time you use when you run one of the shortcuts. Last edited by inameiname; 12-24-2011 at 12:48 PM. | 
|   |   | 
|  12-24-2011, 12:24 PM | #7 | 
| (offline)            Posts: 2,907 Karma: 6736094 Join Date: Dec 2011 Device: K3, K4, K5, KPW, KPW2 | 
			
			Good to see that you solved it. I personally can't test it though, I have a Kindle Touch    | 
|   |   | 
|  12-24-2011, 12:31 PM | #8 | 
| Groupie            Posts: 159 Karma: 20390 Join Date: Feb 2009 Device: none | |
|   |   | 
|  12-31-2011, 01:39 AM | #9 | 
| Junior Member  Posts: 1 Karma: 10 Join Date: Dec 2011 Device: Kindle 3 | 
				
				It's working!
			 
			
			Thanks a lot for this script   I've been wanting to change the timeout but still hesistant to manually edit the file. I'm running on 3.1 and so far, it' running without bugs. I've used both the 30 and 60 minutes. | 
|   |   | 
|  01-02-2012, 01:14 AM | #10 | 
| Groupie            Posts: 159 Karma: 20390 Join Date: Feb 2009 Device: none | 
			
			That's great. I am glad it is working for you. I was waiting to hear from others whether or not it was working.
		 | 
|   |   | 
|  01-03-2012, 10:23 AM | #11 | 
| Connoisseur            Posts: 65 Karma: 4662 Join Date: Feb 2011 Location: CZ Device: Kindle Touch 3G, Kindle Keyboard | |
|   |   | 
|  03-08-2012, 12:48 AM | #12 | 
| Member  Posts: 14 Karma: 28 Join Date: Feb 2012 Device: Kindle Touch, Nook Color | |
|   |   | 
|  03-08-2012, 02:59 AM | #13 | |
| Wizard            Posts: 1,669 Karma: 2300001 Join Date: Mar 2011 Location: Türkiye Device: Kindle 5.3.7 | Quote: 
  I will try to add this to SSModeSwitcher | |
|   |   | 
|  04-13-2012, 08:25 PM | #14 | 
| Connoisseur            Posts: 58 Karma: 9096 Join Date: Apr 2012 Device: none | 
				
				hello,i want mplayer to be killed in a time(my bad english!)
			 
			
			hello!I come from china!Excuse my poor english! i usually listen to music before sleeping,mostly i fall asleep without shuting down my kindle! so i want my kindle's mplayer to be killed in a time that can be set! i think it is useful because i have many friend , is not that? thank you! Last edited by xueyou2; 04-13-2012 at 08:28 PM. | 
|   |   | 
|  04-14-2012, 03:03 AM | #15 | |
| Addict            Posts: 251 Karma: 183457 Join Date: Jan 2012 Device: k3G, KDXG, AuraHD | Quote: 
  Code: lipc-wait-event -s 0 com.lab126.powerd goingToScreenSaver && killall mplayer | |
|   |   | 
|  | 
| Thread Tools | Search this Thread | 
| 
 | 
|  Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post | 
| Hacks Tweak sleep/screensaver timeout on Kindle 3 | rastik | Amazon Kindle | 6 | 01-03-2012 07:09 PM | 
| Touch Custom screensaver timeout on rooted touch | illumilore | Nook Developer's Corner | 0 | 11-27-2011 02:23 AM | 
| Screensaver ads do not change? | caihuire | Amazon Kindle | 6 | 10-19-2011 09:47 PM | 
| Hacks Change screen saver timeout - K2i v.2.5 | supakdee | Amazon Kindle | 6 | 10-14-2011 12:11 PM | 
| Can not change the gotosleep timeout | linshi | Kindle Developer's Corner | 1 | 06-28-2011 07:19 AM |