[G1 Android Development] Firerat:
Hi all

I added Loccy's script to my latest Vega's Legend CacheHack

my ramdisks init.rc is launching /system/patch on boot

I made a few changes,

replaced the stat cmd with du

changed the log location to the tmpfs ( /dev/ )

its working great, out of the box ;)

here is a diff patch

--- lightbodge.txt	2010-04-14 12:50:42.000000000 +0100
+++ FR-lightbodge.txt	2010-04-14 12:51:36.000000000 +0100
@@ -5,7 +5,11 @@
KEYBOARD_OPEN="keys=2/1/1"
KEYBOARD_CLOSE="keys=2/1/2"

-BASE_DIR="/sdcard/logcatmon"
+BASE_DIR="/dev/logcatmon"
+if [ ! -d $BASE_DIR ];
+then
+	mkdir $BASE_DIR
+fi

FILE_SCREENON="$BASE_DIR/logcat-screenon.txt"
FILE_SCREENONX="$BASE_DIR/logcat-screenonX.txt"
@@ -22,13 +26,13 @@
DEVICE_BUTTONLIGHT="/sys/class/leds/button-backlight/brightness"
DEVICE_KEYBOARDLIGHT="/sys/class/leds/keyboard-backlight/brightness"

-echo "Changing privs."
-chmod 777 $DEVICE_BUTTONLIGHT
-chmod 777 $DEVICE_KEYBOARDLIGHT
-
-echo "Monitoring logcat"
-rm -r $BASE_DIR
-mkdir $BASE_DIR
+#echo "Changing privs."
+#chmod 777 $DEVICE_BUTTONLIGHT
+#chmod 777 $DEVICE_KEYBOARDLIGHT
+
+#echo "Monitoring logcat"
+#rm -r $BASE_DIR
+#mkdir $BASE_DIR

# monitor for screen going off
logcat -d | grep "$SCREEN_OFF" > $FILE_SCREENOFF
@@ -50,39 +54,39 @@
do

# if screen on
-FILESIZE=`stat -c%s $FILE_SCREENON`
-FILESIZE2=`stat -c%s $FILE_SCREENONX`
+FILESIZE=`busybox du $FILE_SCREENON|cut -f1`
+FILESIZE2=`busybox du $FILE_SCREENONX|cut -f1`
if [ ! $FILESIZE -eq $FILESIZE2 ]; then
echo "Screen turned on"
echo 1 > /sys/class/leds/button-backlight/brightness
-logcat -d | grep "$SCREEN_ON" > /sdcard/logcatmon/logcat-screenonX.txt
+logcat -d | grep "$SCREEN_ON" > ${BASE_DIR}/logcat-screenonX.txt
fi;

# if screen off
-FILESIZE=`stat -c%s $FILE_SCREENOFF`
-FILESIZE2=`stat -c%s $FILE_SCREENOFFX`
+FILESIZE=`busybox du $FILE_SCREENOFF|cut -f1`
+FILESIZE2=`busybox du $FILE_SCREENOFFX|cut -f1`
if [ ! $FILESIZE -eq $FILESIZE2 ]; then
echo "Screen turned off"
echo 0 > /sys/class/leds/button-backlight/brightness
-logcat -d | grep "$SCREEN_OFF" > /sdcard/logcatmon/logcat-screenoffX.txt
+logcat -d | grep "$SCREEN_OFF" > ${BASE_DIR}/logcat-screenoffX.txt
fi;

# if keyboard opened
-FILESIZE=`stat -c%s $FILE_KEYBOARDOPEN`
-FILESIZE2=`stat -c%s $FILE_KEYBOARDOPENX`
+FILESIZE=`busybox du $FILE_KEYBOARDOPEN|cut -f1`
+FILESIZE2=`busybox du $FILE_KEYBOARDOPENX|cut -f1`
if [ ! $FILESIZE -eq $FILESIZE2 ]; then
echo "Keyboard opened/rotated to landscape"
echo 1 > /sys/class/leds/keyboard-backlight/brightness
-logcat -d | grep "$KEYBOARD_OPEN" > /sdcard/logcatmon/logcat-keyboardopenX.txt
+logcat -d | grep "$KEYBOARD_OPEN" > ${BASE_DIR}/logcat-keyboardopenX.txt
fi;

# if keyboard closed
-FILESIZE=`stat -c%s $FILE_KEYBOARDCLOSE`
-FILESIZE2=`stat -c%s $FILE_KEYBOARDCLOSEX`
+FILESIZE=`busybox du $FILE_KEYBOARDCLOSE|cut -f1`
+FILESIZE2=`busybox du $FILE_KEYBOARDCLOSEX|cut -f1`
if [ ! $FILESIZE -eq $FILESIZE2 ]; then
echo "Keyboard opened/rotated to portrait"
echo 0 > /sys/class/leds/keyboard-backlight/brightness
-logcat -d | grep "$KEYBOARD_CLOSE" > /sdcard/logcatmon/logcat-keyboardcloseX.txt
+logcat -d | grep "$KEYBOARD_CLOSE" > ${BASE_DIR}/logcat-keyboardcloseX.txt
fi;

sleep 1