#!/bin/busybox sh
if [ $# -eq 0 ] ; then
+ verbose=1 # output msg to stderr
wnkCyc=$(mktemp /tmp/whinkerCyc_XXXXXX)
printf 'CycleFile: ' 1>&2
echo $wnkCyc
4. Stop whinker
PROMPT# rm $wnkCyc
- Inside scripts use: wnkCyc=\`mktemp\`; /path/to/${0##*/} \$wnkCyc
+ * Inside scripts, use:
+ wnkCyc=\$($0 .)
+ printf '200 99 99 0\n200 0 99 99\n200 99 0 99\n' >\$wnkCyc
+ ## proc 1
+ echo '600 99 99 99' >>\$wnkCyc
+ ## proc 2
+ printf '10 0 99 0\n800 0 0 0\n' >\$wnkCyc
+ ## proc 3
+ rm \$wnkCyc # stop
EOEXAMPLE
else
- [ -f "$1" ] || exit 1
- wnkCyc="$1"
+ verbose=0 # no output to stderr
+ if [ -f "$1" ] ; then
+ wnkCyc="$1"
+ else
+ wnkCyc=$(mktemp /tmp/whinkerCyc_XXXXXX)
+ echo $wnkCyc
+ fi
fi
-
+
# format of $wnkCyc
# period(msec 1-2000) red(0-255) green(0-255) blue(0-255)
# finish if $wnkCyc is deleted
echo 0 >$ledR
echo 0 >$ledG
echo 0 >$ledB
- [ $# -eq 0 ] && echo "whinker $wnkCyc stopped" 1>&2
+ [ $verbose -eq 1 ] && echo "whinker $wnkCyc stopped" 1>&2
exit 0
fi
wwait=250 # msec
wwait=""
done < $wnkCyc 2>/dev/null
[ -n "$wwait" ] && usleep $((wwait*1000))
-done &
+done >/dev/null &
exit
#!/bin/busybox sh
-defaultPath='/mnt/onboard/.fakesh/images'
+if [ -d "$FKSH_ONB" ] ; then
+ # in the system of fakesh
+ defaultPath="$FKSH_ONB/images"
+ [ -d "$defaultPath" ] || defaultPath='.'
+else
+ # without the system of fakesh
+ defaultPath='.'
+fi
+
showUsage () {
cat 1>&2 <<- EOUSG
- Usage: ${0##*/} [ N | repeatN | file | file.gz ] ...
- N : at most 4 degits of wait period (msec).
- repeatN : at most 3 degits of times of repeatition.
- file | file.gz : abs path /path/to/file[.gz] ,
- rel path ./path/to/file[.gz] or
- default path [$defaultPath/]path/to/file[.gz]
+ Usage: ${0##*/} [ file | file.gz | N | repeatN ]
+ file | file.gz : path to a file to display.
+ default path ${defaultPath}/file[.gz]
+ N : at most 4 digits of wait period (msec).
+ repeatN : at most 4 digits of times of repeatition.
Usage: ${0##*/} -i file.seq
- args are the 1st flds of every line of file file.seq .
+ input args from the 1st flds of every line of file.seq .
+ default path ${defaultPath%/*}/file.seq
EOUSG
exit
}
pickel='/usr/local/Kobo/pickel showpic 1'
slp=:
-rep=''
+rep=1
parseArgs () {
local p
case "$1" in
-*) showUsage ;;
- 0 | 00 | 000 | 0000 ) slp=: ;;
+ 0 | 00 | 000 | 0000 )
+ slp=:
+ return
+ ;;
[1-9] | [0-9][0-9] | [0-9][0-9][0-9] | [0-9][0-9][0-9][0-9] )
slp=${i#00}; slp=${slp#0}
slp="usleep $((slp*1000))"
;;
- repeat[2-9] | repeat[1-9][0-9] | repeat[1-9][0-9][0-9] )
- [ -z "$rep" ] && rep=${i#repeat}
+ rep*[0-9])
+ rep="${i##*[!0-9]}"; rep=${rep#00}; rep=${rep#0}
+ [ -z "$rep" ] && rep=1
;;
/*.gz | ./*.gz )
if [ -f "$1" -a -r "$1" ] ; then
$slp ; zcat "$1" | $pickel
fi
;;
- /* | ./*)
+ /* | ./* )
if [ -f "$1" -a -r "$1" ] ; then
$slp ; $pickel < "$1"
fi
while read -r i dum ; do
parseArgs "$i"
done < "$seq"
- [ -z "$rep" ] && break
rep=$((rep-1))
[ $rep -le 0 ] && break
done
for i do
parseArgs "$i"
done
- [ -z "$rep" ] && break
rep=$((rep-1))
[ $rep -le 0 ] && break
done
#!/bin/busybox sh
#
# exit 1 is not fatal
-export LANG=C LC_ALL=C
+export LANG=C LC_ALL=C GZIP=-9
df /tmp | awk '$NF=="/tmp"&&$4<4096{exit 1;}' || exit 1
pickel=/usr/local/Kobo/pickel
if [ -x $pickel ] ; then
*) fmt="${0%.*}" ;;
esac
-# output format switch, jpeg, ppm, pgm;
+# output format switch, jpeg, ppm, pgm, raw;
# G)rayscale, [1234])bit, L)andscape, r)everse video
case "$fmt" in
*g) ext=jpg; dp=8; hdpos=1; fil1=toP3i; fil2=sed_cjpeg ;;
*raw3r) ext=raw.gz; dp=3; hdpos=1; fil1=toRAWG; fil2=gzip ;; # G, 3bit, L, r
*raw2) ext=raw.gz; dp=2; hdpos=0; fil1=toRAWG; fil2=gzip ;; # G, 2bit, L
*raw2r) ext=raw.gz; dp=2; hdpos=1; fil1=toRAWG; fil2=gzip ;; # G, 2bit, L, r
-*raw1) ext=raw.gz; dp=1; hdpos=0; fil1=toRAWG; fil2=gzip ;; # BW, L
-*raw1r) ext=raw.gz; dp=1; hdpos=1; fil1=toRAWG; fil2=gzip ;; # BW, L, r
-*) ext=raw.gz; fmt=raw; dp=1 ;; # raw, landscape, set $dp to 1
+*raw1) ext=WB.raw.gz; dp=1; hdpos=0; fil1=toRAWG; fil2=gzip_rv2 ;; # BW, L, +r
+*rawr) ext=raw.gz; fmt=rawr; dp=1 ;; # raw, L, set $dp to 1, r
+*) ext=raw.gz; fmt=raw; dp=1 ;; # raw, L, set $dp to 1
esac
# set waiting file $pictw
exit 0
esac
+# select options of "od" command
case "$bpp/$rB" in
/* | */ ) rm -f "$pictw"; exit 5 ;; # not a comment of C @_@
8/*) odcmd='od -v -A n -t u1 --width='${SSODWD:-32768} ;;
*) rm -f "$pictw"; exit 6 ;;
esac
-## w*h*bpp/8 is too large, i think, it is beyond pipe capa.
+# select parameters of "dd" command
+# w*h*bpp/8 is too large, i think, it is beyond pipe capa.
bs=$((w*h*bpp/8)); cnt=1
while [ $bs -ge 65536 ] ; do
[ $((bs%1)) -eq 1 ] && break # hardly breaks
dda="bs=$bs count=$cnt"
## shoot
-tmpimg=`mktemp /tmp/scrn.XXXXXX`
-tmpict=`mktemp /tmp/pict.XXXXXX`
+wd=`mktemp -d /tmp/ss_XXXXXX`
case "$opts${0##*/}" in
*/conv*)
- gzip -d > $tmpimg
+ gzip -d > $wd/raw
;;
*)
- if ! dd if=/dev/fb0 of=$tmpimg $dda ; then
- rm -f $tmpimg $tmpict "$pictw"
+ if ! dd if=/dev/fb0 of=$wd/raw $dda ; then
+ rm -rf $wd "$pictw"
exit 7
fi
dd if=/dev/zero $dda | $pickel showpic 1
- $pickel showpic 1 < $tmpimg
+ $pickel showpic 1 < $wd/raw
;;
esac 2>/dev/null
-## set parameters
+## set parameters for conversion
export TMPDIR=/tmp # for the command sort. stupid solution ^o^;
xf=5 # num of hexadecimal figures
[ $((w*h)) -ge $(printf %d 0x100000) ] && xf=6
} | gzip
}
+gzip_rv2 () {
+ tee $wd/BW.raw | tr \\0\\377 \\377\\0 | gzip
+ gzip $wd/BW.raw
+}
+
#### convert
convert () {
if [ $fmt = raw ] ; then
# output to _img_.raw.gz
- gzip -c $tmpimg
+ gzip < $wd/raw
+ elif [ $fmt = rawr ] ; then
+ # output to _img_.raw.gz rv
+ rvFF=' '
+ n=0
+ while [ $n -le 255 ] ; do
+ rvFF="$(printf '\\%o%s\\%o' $n "$rvFF" $n)"
+ n=$((n+1))
+ done
+ tr $rvFF < $wd/raw | gzip
else
- $odcmd $tmpimg | $fil1 | $fil2 "$@"
- fi > $tmpict
- rm -f $tmpimg
+ $odcmd $wd/raw | $fil1 | $fil2 "$@"
+ fi > $wd/$ext
+ rm -f $wd/raw
[ $pickel = : ] || case "$pictw" in
/mnt/onboard/*)
while : ; do
;;
esac
rm -rf "${pictw%.wait}"
- mv $tmpict "${pictw%.wait}"
- rm -f "$pictw"
+ mv $wd/$ext "${pictw%.wait}"
+ [ -f $wd/BW.raw.gz ] && mv $wd/BW.raw.gz "${pictw%.W*}.BW.raw.gz"
+ rm -rf "$wd" "$pictw"
}
+## main
case "$opts" in
*/wait*)
+ [ $ext = WB.raw.gz ] && echo "output: ${pictw%.W*}.BW.raw.gz"
echo "output: ${pictw%.wait}"
convert "$@"
exit
;;
esac
-
+exit
################ TEST CODES ################
-exit; exit; exit; exit; exit; exit;
+exit
################################################################
## check "awk" cannot output NUL : it is libc's printf?
cat > test-awkOutputNUL.sh << 'EOCODE1'
done
################################################################
-## BUGGY busybox "tr"
+## BUGGY? busybox "tr"
cat > test-tr.sh << 'EOCODE3'
#!/bin/busybox sh
export LANG=C LC_ALL=C
./test-tr.sh 0 255
################################################################
-## Can "sed" outpu NUL
+## Can "sed" output NUL
cat >| test-sed.sh << 'EOCODE4'
#!/bin/busybox sh
tmpsed=`mktemp /tmp/sed.XXXXXX`