View Single Post
Old 02-15-2024, 07:17 PM   #9
elinkser
Groupie
elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.
 
Posts: 185
Karma: 146236
Join Date: Oct 2022
Device: Kobo Clara HD
It works!
Even with different script names.
Thanks for this great feature, raisjn .
It opens the door to multiple scriptable GUI apps on Kobo.


***

Another example:

We used netpbm's pnmscale and pnmtopng to help with converting our phone camera jpeg images to rmkit's Harmony drawing app png layers here:
https://www.mobileread.com/forums/sh...62&postcount=8

Now with rmkit's SAS we can do the image conversion in a GUI app instead of runnning the script in a terminal:


# nano -l /mnt/onboard/.adds/rmkit/bin/apps/j2p.sh
Code:
#!/bin/ash
# j2p.sh - rmkit SAS script to convert jpeg images to png

while true; do
  app="
label 200 50 300 50 Jpg searchterm
textinput:input1ID 200 100 300 50 ${inputSearch}
[paragraph 200 200 500 400 ${jpgList}]
label 200 800 300 50 Jpg to convert: ${jpgSelected}
label 200 850 300 50 Png to output: ${pngFilename}
textinput:input2ID 200 900 300 50 ${inputFilename}
button 150 1000 200 50 Portrait
button 350 1000 200 50 Landscape
@fontsize 48
label 200 1100 200 50 ${option}
"
  echo "APP IS"
  echo "${app}"
  output=`echo "${app}" | /mnt/onboard/.adds/rmkit/bin/apps/simple`

  if (expr "${output}" : "input: input1ID" > /dev/null); then
    echo "CLICKED inputSearch"
    inputSearch=`echo ${output} | sed 's/input:.*://'` 
    inputSearch=`echo ${inputSearch} | sed 's/[^-A-Za-z0-9_\.]//g'`
    jpgSearch=`echo "${inputSearch}"*.jpg`
    jpgList=`cd /mnt/onboard/.adds/rmkit/data/harmony/ && ls -a ${jpgSearch}`
    jpgTemp=`echo ${jpgList} | sed 's/ .*/ /'`
    jpgSelected=${jpgTemp}
    inputFilename=`echo ${jpgSelected} | sed 's/\.jpg/\.png/'`
    pngFilename=${inputFilename}
  fi

  if (expr "${output}" : "input: input2ID" > /dev/null); then
    echo "CLICKED inputFilename"
    pngFilename=`echo ${output} | sed 's/input:.*://'`
    pngFilename=`echo ${pngFilename} | sed 's/[^-A-Za-z0-9_\.]//g'`
    inputFilename=${pngFilename}
  fi

  if (expr "${output}" : ".*Portrait" > /dev/null); then
    echo "CLICKED Portrait"
    option="Output to Portrait"
    cd /mnt/onboard/.adds/rmkit/data/harmony/ && export PATH=$PATH:/mnt/onboard/.adds/koreader/scripts && export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/mnt/onboard/.adds/koreader/libs && jpegtran -grayscale ${jpgSelected} |  djpeg -pnm | pnmscale -width 1088 -height 1488 | pnmtopng -alpha a50.pgm > ${pngFilename}
  fi
  if (expr "${output}" : ".*Landscape" > /dev/null); then
    echo "CLICKED Landscape"
    option="Output to Landscape"
    cd /mnt/onboard/.adds/rmkit/data/harmony/ && export PATH=$PATH:/mnt/onboard/.adds/koreader/scripts && export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/mnt/onboard/.adds/koreader/libs && jpegtran -rotate 90 -grayscale ${jpgSelected} | djpeg -pnm | pnmscale -width 1088 -height 1488 | pnmtopng -alpha a50.pgm > ${pngFilename}
  fi
  sleep 0.1
done
***

Last edited by elinkser; 02-23-2024 at 10:30 AM. Reason: jtop SAS example-cleaned up
elinkser is offline   Reply With Quote