![]() |
#1 |
Carpe diem, c'est la vie.
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
![]()
EDIT: This script pauses the framework to prevent typing on the Kindle 3 keyboard from interacting with the framework (search bar). To exit the shell and resume the framework, type the "exit" command. If you run this script on a Kindle 4 or Touch, you will not be able to type an "exit" command, so you will need to resume the framework from SSH, or restart your kindle (hold power switch for 20 seconds). Do not panic just because the framework is paused. Just restart.
![]() tinysh UPDATE: This post was changed so the script code is now in a CODE box instead of a PHP box, which was hiding the "triple backslash" in the "eicho" function. It lost its pretty colors! ![]() This is a tiny limited onscreen shell written in /bin/sh with minimal external linux command dependencies. This first version is only for the K3, but I plan to add support for onscreen keyboards for K4 and Touch. I have most of the code nearing completion for that. For now, this is just for the K3, and with a little work it should work on the DXG and earlier. It is severely limited by eips text support not allowing many characters needed in linux shell commands. Although eips is rather slow on the K3, it is extremely fast on the K4 and Touch, even when scrolling text (so fast that you need to insert delays to not just have a blur of smeared text scrolling faster than you can see it). On the K3, you only get a couple of lines per second or so, but it is better than nothing until we get a faster and better eips replacement. It can be made several time faster by NOT scrolling the text, but instead adding "(Press any key to continue . . .)" and waiting for a key, then redrawing a new screen full of text. Code:
#!/bin/sh #=================================================== # tinysh - tiny limited onscreen shell (v1.0) for K3 #--------------------------------------------------- # Copyright (C) 2012 geekmaster # MIT License: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #=========================== # initvar - init global vars #--------------------------- initvar() { SYM=126 ENT=28 SHFT=42 SPC=57 DEL=14 DN=/dev/null KN="1234567890____qwertyuiop____asdfghjkl_____zxcvbnm_." KS="1234567890____QWERTYUIOP____ASDFGHJKL_____ZXCVBNM_," KP="1234567890____~@#$%^&*()____<>[]{}?/\_____;:'|-+=_?" KM=$KN B=" ";B="$B$B$B$B$B";B="$B$B" CMD= # cmd line } #============================================= # shcmd - emit shell command, preceeded by pwd #--------------------------------------------- shcmd() { echo "echo \"\$(pwd)> $CMD\";$CMD" CMD= } #=================================================== # getkb - get translated ascii keys from K3 keyboard #--------------------------------------------------- getkb() { shcmd while :;do A="_" set $(waitforkey); K=$1 D=$2 [[ $D -eq 0 ]]&& continue [[ $K -eq $ENT ]]&& shcmd && continue [[ $K -eq $SHFT ]]&& KM=$KS && continue [[ $K -eq $SYM ]]&& KM=$KP && continue [[ $K -eq $DEL ]]&& if [[ ${#CMD} -gt 1 ]]; then CMD=$(echo "$CMD"|cut -b-$((${#CMD}-1))) else CMD=; fi [[ $K -eq $SPC ]]&& A=" " [[ $K -le 52 ]]&& A="$(echo \"$KM\"|cut -b$K-$K)" [[ "$A" == "_" ]]&& A="" CMD="$CMD$A" eips "$(echo "~~~> $CMD$B"|cut -b-50)" KM=$KN done } #==================== # eicho - eink echo # usage: eicho "text" #-------------------- eicho() { eips -z 2 38 eips 0 39 "$(echo "$1"|tr ";{}\\\`!#$%^" _|cut -b-50)" } initvar # init global vars killall -stop cvm launchpad 2>$DN eips -c;eips "~~~~~~~~~~~~ Geekmaster Tiny Shell 1.0 ~~~~~~~~~~~" getkb|sh 2>&1|while read l;do eicho "$l";done killall -cont cvm launchpad 2>$DN To improve this, we need to eliminate the dependency on eips for text output. I plan to do graphics blitting (block image copy) from an image of characters using "dd", for graphics text output. Or using Hershey vector fonts, if I finish that first. I plan to start with Hershey Simplex characters -- other language support can be added later. This only works on the K3, but should be easy to adapt to DX and earlier. I even abstracted the keycodes out to initvar so they are easier to change. Be sure your kindle is ON for the keyboard to work. If the keyboard is not echoing keys to the eink display, slide your power switch to wake your kindle and unlock the keyboard, then try again. The "Sym" key is used as a symbol shift key, and all symbols on a standard keyboard can be created on the K3 keyboard except the underscore and double-quote keys (see the KP string assignment in initvar below), but those can be supported too with a little additional code. This script is really just a proof-of-concept example, for educational purposes to show how you can do interesting stuff with shell scripts. To avoid confusion if you plan to modify this, "|while .. read .. do" loop contents run in a separate process space that uses a COPY of the shell variables. Code outside the loop cannot see changes to values inside the loop. You can only pass STDOUT to code outside the loop. That goes for functions called from inside the loop too. You can pass multiple values with STDOUT then extract them with "set" (like I did here with the "waitforkey" call). EDIT: This could be used in a RUNME.sh script to provide a simple onscreen linux command shell for debricking. You can type (and use) characters that you cannot see (eips limitation), which is what I called "blind-typing" above. Enjoy! ![]() EDIT: This script pauses the framework to prevent typing on the Kindle 3 keyboard from interacting with the framework (search bar). To exit the shell and resume the framework, type the "exit" command. If you run this script on a Kindle 4 or Touch, you will not be able to type an "exit" command, so you will need to resume the framework from SSH, or restart your kindle (hold power switch for 20 seconds). Do not panic just because the framework is paused. Just restart. Last edited by geekmaster; 04-09-2012 at 08:22 PM. |
![]() |
![]() |
![]() |
#2 |
Groupie
![]() ![]() Posts: 153
Karma: 113
Join Date: Jan 2012
Location: Russia
Device: Kindle Touch
|
Great! Looking forward seeing this working on KTouch
![]() |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 608
Karma: 1588610
Join Date: Jan 2012
Device: Kindle Scribe
|
How do you plan to make an on screen keyboard?
|
![]() |
![]() |
![]() |
#4 |
Carpe diem, c'est la vie.
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
I have 600x800 touchscreen support that is a complete redesign from that used in the "touchpaint" script here: https://www.mobileread.com/forums/sho...d.php?t=170932
It uses a simple "exit button", which shows a primitive form of what is needed to process onscreen keyboard button presses using the touchscreen. I have a new unpublished "touchpaint" program that outputs a graphics display list, which can be replayed at a later time. I have used it for signature capture, but it has other uses. I used the redesigned touchscreen code mentioned above (which will also be used in the final onscreen keyboard script when I publish it). For an onscreen keyboard, you just draw an image of a keyboard, or display a screen capture of one, and define bounding-box coordinates of all the buttons. Then you detect a touch release inside a button and perform its action (usually emitting a character that matches the image on the key). It also helps to have feedback, like inverse display or a larger letter popup (like the apple ipod devices), as you finger moves on and off a defined key region. I plan to support anything with a 5-way pad too (including the K4). And I will keep the keyboard support used here as well. Instead of touches, you can also select keys by moving through them with 5-way arrow keys, which requires that you define "up/down/left/right" links between them. Obviously, the 5-way "select" would perform the action defined by key (just like a touchscreen release). Meanwhile, I have released plenty of example code you can use to make your own onscreen keyboard. Things will get easier with time, as I release more stuff. ![]() Last edited by geekmaster; 03-29-2012 at 01:04 PM. |
![]() |
![]() |
![]() |
#5 |
curly᷂͓̫̙᷊̥̮̾ͯͤͭͬͦͨ ʎʌɹnɔ
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,015
Karma: 50506927
Join Date: Dec 2010
Location: ♁ ᴺ₄₅°₃₀' ᵂ₇₃°₃₇' ±₆₀"
Device: K3₃.₄.₃ PW3&4₅.₁₃.₃
|
@geekmaster FYI.
For some reason, when viewing your first post, the line Code:
eips 0 39 "$(echo "$1"|tr ";{}`!#$%^" _|cut -b-50)" If I quote your post (instead of viewing it) it shows the correct code: Code:
eips 0 39 "$(echo "$1"|tr ";{}\\\`!#$%^" _|cut -b-50)" Last edited by PoP; 03-29-2012 at 04:06 PM. |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Carpe diem, c'est la vie.
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
I just changed tags on the box containing the script code from a php box to a code box. Those characters show now. Thanks.
![]() ![]() That line of code translates all the characters that eips dislikes to underscore, so it does not send complaints to STDERR. The triple-backslash is actually an escaped backslash and an escaped backtick. Thanks for the compliment! I have a lot of interesting code snippets (/bin/sh and C) that I plan to publish when I get around to it. Seeing that others are interested in this makes it seem like less of a waste of my time. Feedback is essential! ![]() ![]() Last edited by geekmaster; 03-29-2012 at 04:52 PM. |
![]() |
![]() |
![]() |
#7 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 130
Karma: 10000
Join Date: Mar 2012
Device: Kindle 3G, Kindle Touch 3G, iRiver Story HD, Sony Reader
|
Hi,
This works for me when I telnet into the K3 via USB, but for some reason does not run well when I use it as a kite script. Also, I think you can break a long line into the next line by the following slight mod: #==================== # eicho - eink echo # usage: eicho "text" #-------------------- eicho() { st=$1 ii=${#st} while [ $ii -ge 0 ] do eips -z 2 38 # scroll eips 0 39 "$(echo $st|tr ";{}\\\`!#$%^" _|cut -b-50)" # write to the bottom st="$(echo $st | cut -b51-$ii)" ii=$(( ii - 50 )) done } which is good for "ls -l" BTW, you are right about the "${s:a:b}" not working in a script. It worked fine in telnet does not work in script. Thanks, James Thanks, James |
![]() |
![]() |
![]() |
#8 | |
Carpe diem, c'est la vie.
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
Quote:
Actually, I was planning to implement line-wrap like that, but I often leave things incomplete when I need sleep. ![]() There are some odd issues when trying to write code that works in all modes on all the kindles. Some things even behave a little differently between diags and main boots on the same kindle. Then things can change with firmware updates. ![]() Thanks for the update. I may get around to adding that to my script posted above... (later). ![]() By the way, you should wrap code in CODE tags: [ code ] ... code here ... [ /code ] except, leave out the spaces around the brackets, which were added here just so you could see them. ![]() Last edited by geekmaster; 03-29-2012 at 10:04 PM. |
|
![]() |
![]() |
![]() |
#9 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 130
Karma: 10000
Join Date: Mar 2012
Device: Kindle 3G, Kindle Touch 3G, iRiver Story HD, Sony Reader
|
Hi GM,
Does the script work without telnet into the k3g. For me it only works if I run ./tinysh from telnet into k3g. I only have kite installed but the kite scripting runs if telnet runs. However, tinysh does not run as a kite script. I do notice that running from telnet of some of the other scripts that the main screen does not update. But running as kite script does. Thanks, James |
![]() |
![]() |
![]() |
#10 | |
Carpe diem, c'est la vie.
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
Quote:
I will need to check that out. There is no obvious reason why the keyboard or display should not be available that I can think of right now... |
|
![]() |
![]() |
![]() |
#11 |
Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 17
Karma: 2600
Join Date: Mar 2012
Device: Kindle 3
|
I used this kite script
Code:
#!/bin/sh /mnt/us/bin/tinysh & Code:
[[ $K -eq $ENT ]]&& shcmd && continue Code:
if [[ $K -eq $ENT ]]; then [[ $CMD == "quit" ]] && exit shcmd && continue fi |
![]() |
![]() |
![]() |
#12 | |
Carpe diem, c'est la vie.
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
Quote:
![]() Remember that the K3 and earlier already have a nicer onscreen shell (I recommend myts-7). This script was meant to be used in special cases, like during debricking, but especially as an example of what you CAN do with a shell script, using ONLY stuff that is already built-in. And modifying this as you are doing is a GREAT learning experience. ![]() P.S. How did you get tinysh working in kite, instead of only telnet as you had previously reported? ![]() Last edited by geekmaster; 03-30-2012 at 06:04 PM. |
|
![]() |
![]() |
![]() |
#13 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 130
Karma: 10000
Join Date: Mar 2012
Device: Kindle 3G, Kindle Touch 3G, iRiver Story HD, Sony Reader
|
Hi GM,
I noticed that I missed copying #!/bin/sh at the very first line, so it ran with telnet by not with kite. It works quite well now. Thanks, James |
![]() |
![]() |
![]() |
#14 |
curly᷂͓̫̙᷊̥̮̾ͯͤͭͬͦͨ ʎʌɹnɔ
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,015
Karma: 50506927
Join Date: Dec 2010
Location: ♁ ᴺ₄₅°₃₀' ᵂ₇₃°₃₇' ±₆₀"
Device: K3₃.₄.₃ PW3&4₅.₁₃.₃
|
I use a similar !/mnt/us/bin/tinysh & launchpad shortcut and I simply enter the exit command in tinysh to exit from the shell. I didn't need to modify the script. Does the kite launcher act differently?
|
![]() |
![]() |
![]() |
#15 | |
Carpe diem, c'est la vie.
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,433
Karma: 10773668
Join Date: Nov 2011
Location: Multiverse 6627A
Device: K1 to PW3
|
Quote:
![]() Thanks for the tip! |
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Help finding tiny towers and tiny zoo | mojkadona | Kindle Fire | 5 | 04-26-2012 07:02 PM |
Kindle onscreen keyboard shortcuts | Conniemartin | Amazon Kindle | 3 | 12-27-2011 02:59 PM |
Night Brothers - Vampire Thriller - 99 cents for a limited timefor a limited time | SidneyW | Self-Promotions by Authors and Publishers | 0 | 07-11-2011 09:49 AM |
Jointech JE100: any bigger onscreen keyboard? | datebtraveller | More E-Book Readers | 1 | 04-30-2010 06:33 AM |
PRS-500 Dictionary for Sony PRS500/5 (autorun from SD card) with onscreen keyboard | Clemenseken | Sony Reader Dev Corner | 3 | 07-05-2008 08:33 AM |