View Single Post
Old 12-24-2011, 05:10 AM   #1
inameiname
Groupie
inameiname can self-interpret dreams as they happen.inameiname can self-interpret dreams as they happen.inameiname can self-interpret dreams as they happen.inameiname can self-interpret dreams as they happen.inameiname can self-interpret dreams as they happen.inameiname can self-interpret dreams as they happen.inameiname can self-interpret dreams as they happen.inameiname can self-interpret dreams as they happen.inameiname can self-interpret dreams as they happen.inameiname can self-interpret dreams as they happen.inameiname can self-interpret dreams as they happen.
 
Posts: 156
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
screensaver_timeout_15.sh (no need to show the 20, 30, 45, etc ones)
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}
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=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: http://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.
Attached Files
File Type: zip screensaver_timeout_ini_and_scripts.zip (7.4 KB, 402 views)

Last edited by inameiname; 04-16-2012 at 10:42 PM. Reason: Edited to show it seems to be fully-working now, rather than merely in the testing phase
inameiname is offline   Reply With Quote