OSDN Git Service

ËÜÂΤ⹹¿·¤·¤Ê¤¤¤È
authorfakesh <fakesh@users.sourceforge.jp>
Mon, 11 Feb 2013 11:57:49 +0000 (20:57 +0900)
committerfakesh <fakesh@users.sourceforge.jp>
Mon, 11 Feb 2013 11:57:49 +0000 (20:57 +0900)
etc/fakesh/tools/genSimpPics.sh
etc/fakesh/tools/koboBackup.sh
etc/fakesh/tools/whinker.sh [changed mode: 0644->0755]
root/bin/dispPics.sh
root/bin/screenShot-jpeg.sh
root/bin/screenShot-rawr.sh [moved from root/bin/screenShot-raw1r.sh with 100% similarity]

index 31e14c8..ea5347c 100755 (executable)
@@ -8,7 +8,7 @@ showUsage () {
          /path/to/imgdir : (default /mnt/onboard/.fakesh/images/)
          pNN : make password panel with line width NN
          cNNN : make checker with unit NNN
-         bNN : make bull's eyes with unit NN
+         bNN : make bull\'s eyes with unit NN
        EOUSG
   exit
 }
index 926b3d7..a6c8577 100755 (executable)
@@ -142,7 +142,6 @@ while [ $n -lt $wSec ] ; do
     if [ $n -eq 0 ] ; then
       rm -f $wnkCyc
       echo "Dont insert mcSD, first. Eject mcSD."
-#      rm -f "$mkBackupLOG"
       exit 3
     else
       printf 'Found'
@@ -180,7 +179,7 @@ exitWithMsg () {
   printf '%s\n\n%s\n\n' "$1" "$(date '+---- %H:%M:%S ----')"
   yel=99
   [ "$2" -eq 0 ] && yel=0
-  printf '10 %d 99 0\n690 0 0 00\n' $yel > $wnkCyc
+  printf '10 %d 99 0\n690 0 0 0\n' $yel > $wnkCyc
   if grep -q "$vol\$" /proc/partitions >/dev/null 2>&1 ; then
     printf 'Please eject mcSD media'
     while : ; do
@@ -190,7 +189,7 @@ exitWithMsg () {
     done
     printf '\nEjected\n\n%s\n\n' "$(date '+---- %H:%M:%S ----')"
   fi
-  printf '500 99 99 99\n400 0 0 00\n' > $wnkCyc
+  printf '500 99 99 99\n400 0 0 0\n' > $wnkCyc
   echo 'Send signal CONT to udevd, etc...'
   for p in $(pidof hindenburg fickel udevd) ; do kill -CONT $p ; done
   echo 'Wait more 12 secs for cleaning pipe'
@@ -216,7 +215,6 @@ exitWithMsg () {
 }
 
 if [ -z "$pz" ] ; then
-  # rm -f "$mkBackupLOG"
   exitWithMsg '+++ NO mcSD media.' 0
 fi
 
old mode 100644 (file)
new mode 100755 (executable)
index b75e548..b15e7ff
@@ -1,6 +1,7 @@
 #!/bin/busybox sh
 
 if [ $# -eq 0 ] ; then
+  verbose=1  # output msg to stderr
   wnkCyc=$(mktemp /tmp/whinkerCyc_XXXXXX)
   printf 'CycleFile: ' 1>&2
   echo $wnkCyc
@@ -27,14 +28,27 @@ if [ $# -eq 0 ] ; then
        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
@@ -57,7 +71,7 @@ while : ; do
     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
@@ -74,7 +88,7 @@ while : ; do
     wwait=""
   done < $wnkCyc 2>/dev/null
   [ -n "$wwait" ] && usleep $((wwait*1000))
-done &
+done >/dev/null &
 
 exit
 
index 07ffeec..cb6e327 100755 (executable)
@@ -1,16 +1,24 @@
 #!/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
 }
@@ -19,26 +27,30 @@ showUsage () {
 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
@@ -69,7 +81,6 @@ if [ "x$1" = x-i ] ; then
     while read -r i dum ; do
       parseArgs "$i"
     done < "$seq"
-    [ -z "$rep" ] && break
     rep=$((rep-1))
     [ $rep -le 0 ] && break
   done  
@@ -80,7 +91,6 @@ while : ; do
   for i do
     parseArgs "$i"
   done
-  [ -z "$rep" ] && break
   rep=$((rep-1))
   [ $rep -le 0 ] && break
 done
index 1192e4b..f38b75f 100755 (executable)
@@ -1,7 +1,7 @@
 #!/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
@@ -30,7 +30,7 @@ case "$opts" in
 *) 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 ;;
@@ -55,9 +55,9 @@ case "$fmt" in
 *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
@@ -130,6 +130,7 @@ case "$opts" in
   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} ;;
@@ -138,7 +139,8 @@ case "$bpp/$rB" in
 *) 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
@@ -147,23 +149,22 @@ done
 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
@@ -304,15 +305,29 @@ P2i2P5gz () {
   } | 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
@@ -328,12 +343,15 @@ convert () {
   ;;
   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
@@ -344,9 +362,9 @@ case "$opts" in
 ;;
 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'
@@ -405,7 +423,7 @@ for i in 0 1 2 255 256 65535 65536 65537 ; do
 done
 
 ################################################################
-## BUGGY busybox "tr"
+## BUGGY? busybox "tr"
 cat > test-tr.sh << 'EOCODE3'
 #!/bin/busybox sh
 export LANG=C LC_ALL=C
@@ -429,7 +447,7 @@ chmod +x test-tr.sh
 ./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`