![]() |
#1 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 109
Karma: 146236
Join Date: Oct 2022
Device: Kobo Clara HD
|
*** SECURITY REMINDER ***
You are browsing as root on an outdated kernel that is not likely to see timely security patches. You should at least create a non-root user (e.g. using adduser), but they would need permission to use the framebuffer i.e. FBInk, if they want to use the graphical image viewer feature. To create a user 'fbuser' with framebuffer access you can do the following: adduser fbuser addgroup fbgroup adduser fbuser fbgroup chgrp fbgroup /dev/fb0 But it looks like you have to redo that last chgrp command each session. Furthermore, Kobo seems to have disallowed write access to /mnt/onboard to anyone but root, so other users cannot save bookmarks to .elinks/ but they can at least save downloads to the /tmp directory (of course you then have to copy them as root to a more permanent location). *NOTE* You can edit the "umask 002" line in /etc/init.d/rcS to "umask 000" allow all user write access to the /mnt/onboard partition, but that would defeat the security objective. You can't have fine-grained access permission because it is a vfat format. When you create a user with "adduser bla", a /home/bla directory is created on the root partition, which DOES have fine-grained access controls, as you can see by running "ls -l /home". But the root partition doesn't have much free space, only about 60MB, as you can see by running "df". So you may prefer "adduser bla -d /mnt/onboard/.adds/koreader/home/bla" to put the home directory on the /mnt/onboard partition which has many GB of free space, which the user won't be able to write to, but at least it doesn't use up valuable root partition space. In retrospect I should have crosscompiled using "--prefix=/mnt/onboard/.adds/koreader/templib" on my desktop instead of "--prefix=$HOME/Downloads/mykobossh/templib", so I wouldn't have to use up valuable root partition space with all the certificates, as you will see. The links near the bottom of this post point to an alternative approach using a chroot. Clara HD owners also have the option to pull out the SD card and shrink the /mnt/onboard partition with a disk utility, then creating a new /home partition that is writable by non-root users. But non-Clara owners can still create a /home partition in an image file, as was done here, (but no need to create root file system - just format it and mount it.) **EDIT - Comment #3 has another way to get elinks by copying and may be easier. Otherwise: 1.Back up your SD card. 2.Don't use your Kobo for sensitive info including passwords. 3.Don't browse to unsafe sites. Or just use Firefox on your desktop to save complete webpage with image folder, or print to pdf on your cellphone, these can be webserved to your Kobo for secure graphic browsing using KOReader! As mentioned here *** HOW TO CROSSCOMPILE ELINKS AND WGET FOR THE KOBO CLARA HD (using linux desktop). --- First, follow the instructions here to determine the crosscompile tool for your device. For the Kobo Clara HD, it is gcc-linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabihf.tar.xz. Download this and source packages for openssl, elinks, and wget to $HOME/Downloads/mykobossh/. --- To build OPENSSL: (see also) cd cd Downloads/mykobossh/ tar xJf gcc-linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabihf.tar.xz export PATH=$PWD/gcc-linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabihf/bin:$PATH tar zxvf openssl-1.1.1s.tar.gz cd openssl-1.1.1s/ mkdir $HOME/Downloads/mykobossh/templib ./Configure gcc -static -no-shared --prefix=$HOME/Downloads/mykobossh/templib --cross-compile-prefix=arm-linux-gnueabihf- make make install cd .. --- To build ELINKS: (see also) tar zxvf elinks-0.15.1.tar.gz cd elinks-0.15.1/ ./autogen.sh ./configure --help ./configure --host=arm-linux-gnueabihf --enable-own-libc --enable-sm-scripting --disable-nls --disable-xbel --disable-ipv6 --disable-leds --disable-backtrace --with-static --without-zlib --without-bzlib --without-gnutls --with-openssl=$HOME/Downloads/mykobossh/templib CPPFLAGS="-I$HOME/Downloads/mykobossh/templib/include" LDFLAGS="-L$HOME/Downloads/mykobossh/templib/lib" make cp src/elinks ../elinks111s cd .. --- DEVICE: Copy elinks111s to .adds/koreader/scripts directory on Kobo Clara HD. Run KOReader and connect to WIFI on Clara HD. Open Terminal Emulator and you will see elinks111s in working directory (/mnt/onboard/.adds/koreader/scripts). chmod +x elinks111s elinks111s (enter "mobileread.mobi/forums/") (keep pressing return key if get ssl error message) ***EDIT*** It helps to copy certificates to a $HOME/Downloads/mykobossh/templib/ssl/certs directory that you must create on your Kobo, where $HOME is /home/user, or whatever your desktop home directory was. I got certificates from my desktop /usr/share/ca-certificates/mozilla directory, but your case may differ. Also, a heavy page like amazon might stall, but I press q then cancel and it seems to get going again! *Update-wget seems to handle certs differently. A workaround might be to copy the ca-certificates.crt file from your desktop (mine was in /etc/ssl/certs) to the above directory, and let wget know by creating a .wgetrc file in /mnt/onboard/.adds/koreader with the single line: ca_certificate=/home/user/Downloads/mykobossh/templib/ssl/certs/ca-certificates.crt (or wherever you saved it). ** Update-Courtesy of qkqw's post, here is another source of Mozilla CA certificates from the Curl website. *** Press Esc key and down arrow key to get menu and key codes. Use spacebar for pagedown and 'b' for pageup, 'g' followed by '.' to browse local filesystem. Press q (followed by return key) to quit --- NiLuJe's FBInk can be configured as an image viewer for elinks, except the image gets quickly overwritten. But it is there long enough to decide if you want to download it. Turns out I had to not use the FBInk that came with my installed KOReader but to download it separately from here. EDIT elinks.conf FILE IN .elinks/ (TO CONFIGURE fbink AS IMAGE VIEWER): set document.browse.images.display_style = 1 set document.browse.images.filename_maxlen = 50 set document.browse.images.image_link_tagging = 2 set document.browse.images.show_as_links = 1 set mime.extension.jpg="image/jpeg" set mime.extension.jpeg="image/jpeg" set mime.extension.png="image/png" set mime.extension.gif="image/gif" set mime.extension.bmp="image/bmp" set mime.extension.pnm="image/pnm" set mime.handler.image_viewer.unix.ask = 1 set mime.handler.image_viewer.unix-xwin.ask = 0 set mime.handler.image_viewer.unix.block = 1 set mime.handler.image_viewer.unix-xwin.block = 0 set mime.handler.image_viewer.unix.program = "/mnt/onboard/.adds/koreader/scripts/fbink -g file=%" set mime.handler.image_viewer.unix-xwin.program = "/mnt/onboard/.adds/koreader/scripts/fbink -g file=%" set mime.type.image.jpg = "image_viewer" set mime.type.image.jpeg = "image_viewer" set mime.type.image.png = "image_viewer" set mime.type.image.gif = "image_viewer" set mime.type.image.bmp = "image_viewer" set mime.type.image.pnm = "image_viewer" --- *EDIT* Actually "fbink -G -g file=% ;sleep 2" keeps the image longer. I tried appending 2>/dev/null but that only helps outside of elinks. *You need that space between "%" and ";" for some reason. Another option is: "fbink -G -y 30 -g file=% ;sleep 2" Which keeps the image to the lower part of the display, so it doesn't get overwritten. --- To build WGET: (see also) tar zxvf wget-1.21.tar.gz cd wget-1.21/ ./configure --help env CPPFLAGS="-I$HOME/Downloads/mykobossh/templib/include" LDFLAGS="-L$HOME/Downloads/mykobossh/templib/lib" ./configure --with-ssl=openssl --with-libssl-prefix=$HOME/Downloads/mykobossh/templib --target=arm-linux-gnueabihf --host=arm-linux-gnueabihf --disable-nls --disable-ipv6 --without-zlib make CPPFLAGS="-I$HOME/Downloads/mykobossh/templib/include" LDFLAGS="-L/$HOME/Downloads/mykobossh/templib/lib -static" cp src/wget ../wget111s DEVICE: Copy wget111s to .adds/koreader/scripts directory on Kobo Clara HD. Run KOReader and connect to WIFI on Clara HD. Open Terminal Emulator and you will see wget111s in working directory (/mnt/onboard/.adds/koreader/scripts). chmod +x wget111s wget111s google.com ls index.html Here is a more sophisticated use: ***NOTE THE VERY IMPORTANT OPTION '-Q50M' WHICH LIMITS DOWNLOAD TO 50MB !!!*** (this is to keep you from inadvertently "downloading the internet") wget111s --no-check-certificate --no-parent -k -nd -D www.mobileread.mobi -E -r -A jpg,jpeg,png,gif,htm.html -l1 -Q50M -P ./mywgets/ www.mobileread.mobi/forums/ ------ THE NEXT SECTIONS ARE OPTIONAL, IF YOU WANT AN ASCIIVIEW IMAGE VIEWER. *It is for ascii images - not high resolution images, from when I could not get NiLuJe's FBInk to work within elinks. So this is mostly just a fun substitute! Spoiler:
Finally, if you have gotten this far and said, whew, that was a lot, then "HOWTO Create your own native development environment on your Kobo!" might be making a lot more sense now! *EDIT:Looks like graphical browser with Xorg is also available via chroot. Extra Clara HD config steps on post #46.. So there you have an almost graphical browser. *Actually, if you use wget (the real one you compiled above, or maybe the cURL binary installed from NiLuJe's kobostuff package - not the stripped-down one that comes with KOReader) you can with a little practice download a page WITH images and that can be opened WITH IMAGES(if they are local, like saved as complete webpage by Firefox) in KOReader for a graphical view! Last edited by elinkser; 04-24-2023 at 02:51 PM. Reason: alt install |
![]() |
![]() |
![]() |
#2 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 109
Karma: 146236
Join Date: Oct 2022
Device: Kobo Clara HD
|
***TO DOWNLOAD "COMPLETE" WEB PAGE (Firefox-style)***
Follow instructions at this link to add uri passing to our cross-compiled wget111s command from above, except name the entry "wgets", use the command "wget111s --no-check-certificate --show-progress -nd -E -k -p -Q20M %c", and assign keybinding "Ctrl-W". Press ENTER key and save by tabbing to the "SAVE" button and pressing ENTER, then ESC to get back to current page. Now, if you press g, then "g" for google, followed by ENTER, elinks will take you to the google search page. Enter "Ctl-w" and complete web page is saved to current directory. To verify, press g, then "." for current local directory, followed by ENTER, then maybe "Ctrl-r" to refresh cache, and a few down-arrow presses to scroll, and voila, your complete web page with images! Now if you want to browse this page in the luxury of the KOReader environment, turn off networking to be sure you are looking at locally saved files, and browse to your download directory in KOReader to see the "complete" web page with images displayed. *Note-this option was done while running elinks111s as root, so that the change would be written to the elinks.conf file. *LONG INSTRUCTIONS FROM LINK: Spoiler:
Last edited by elinkser; 01-16-2023 at 12:06 PM. Reason: remove link dependency |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 109
Karma: 146236
Join Date: Oct 2022
Device: Kobo Clara HD
|
***PLS SEE SECURITY REMINDER ON TOP POST***
COPYING ELINKS BINARY TO KOBO CLARA HD WITHOUT COMPILING OR CHROOT: (Some may find this an easier way to get the elinks browser.) You can see dependencies of elinks from here. Depends (6) libbz2 libcrypto3 libexpat libssl3 musl zlib You can get the packages from here. You can get a CA certificate store from here. DOWNLOAD THE REQUIRED PACKAGES: $ wget https://dl-cdn.alpinelinux.org/alpin...-0.15.1-r1.apk $ wget https://dl-cdn.alpinelinux.org/alpin...2-1.0.8-r4.apk $ wget https://dl-cdn.alpinelinux.org/alpin...3-3.0.8-r1.apk $ wget https://dl-cdn.alpinelinux.org/alpin...t-2.5.0-r0.apk $ wget https://dl-cdn.alpinelinux.org/alpin...3-3.0.8-r1.apk $ wget https://dl-cdn.alpinelinux.org/alpin...l-1.2.3-r4.apk $ wget https://dl-cdn.alpinelinux.org/alpin...-1.2.13-r0.apk $ wget https://curl.se/ca/cacert.pem RUN THESE COMMANDS FROM LINUX DESKTOP OR ENVIRONMENT(really just need to unarchive and copy some files, but the tar command fails if you try it on the vfat filesystem /mnt/onboard of the Kobo because of vfat not supporting symlinks. I didn't try on the root filesystem partition e.g. /opt): $ mkdir myalpine $ cd myalpine/ $ tar zxvf elinks-0.15.1-r1.apk $ tar zxvf libbz2-1.0.8-r4.apk $ tar zxvf libcrypto3-3.0.8-r1.apk $ tar zxvf libexpat-2.5.0-r0.apk $ tar zxvf libssl3-3.0.8-r1.apk $ tar zxvf musl-1.2.3-r4.apk $ tar zxvf zlib-1.2.13-r0.apk $ mkdir scripts $ mv usr/bin/elinks scripts/ $ ls -l scripts/ -rwxr-xr-x 923356 elinks $ mkdir libs $ mv usr/lib/libbz2.so.1.0.8 libs/libbz2.so.1 $ mv lib/libcrypto.so.3 libs/ $ mv usr/lib/libexpat.so.1.8.10 libs/libexpat.so.1 $ mv lib/libssl.so.3 libs/ $ cp lib/ld-musl-armhf.so.1 libs/libc.musl-armv7.so.1 $ mv lib/ld-musl-armhf.so.1 libs/ $ mv lib/libz.so.1.2.13 libs/libz.so.1 $ ls -l libs -rwxr-xr-x 525980 ld-musl-armhf.so.1 -rwxr-xr-x 69772 libbz2.so.1 -rwxr-xr-x 525980 libc.musl-armv7.so.1 -rwxr-xr-x 2233828 libcrypto.so.3 -rwxr-xr-x 132444 libexpat.so.1 -rwxr-xr-x 405904 libssl.so.3 -rwxr-xr-x 66856 libz.so.1 $ cp cacert.pem cert.pm $ mkdir certs $ cp cacert.pem certs/ca-certificates.crt NOW CONNECT YOUR KOBO TO YOUR PC: Note the contents of /mnt/onboard/.adds/koreader/scripts/ does not have any elinks binary. Copy your elinks binary from the scripts/ folder on the PC to the /mnt/onboard/.adds/koreader/scripts/ folder on the kobo. Note the contents of /mnt/onboard/.adds/koreader/libs/ already has a libz.so.1 lib. Copy all libs except libz.so.1 from the libs/ folder on the PC to the /mnt/onboard/.adds/koreader/libs/ folder on the kobo. Note that these new libs all have a different date than the default pre-existing libs. Copy your cert.pm and certs/ca-certificates.crt to the /etc/ssl/ directory.(You may notice there is already one in the /mnt/onboard/.adds/koreader/data/ folder anyway.) RUN THESE COMMANDS IN KOREADER TERMINAL, OR FROM A TELNET/SSH CLIENT CONNECTION: ***SECURITY REMINDER*** Telnet sessions are in cleartext INCLUDING LOGIN SESSIONS, so only use on a private network, if at all! If you always have DEVMODE set to ON for whatever reasons , that means Telnet is on by default, unless you toggle it off , e.g. using NickelMenu. You can install KOReader to get the more secure SSH option, and NiLuJe's kobostuff provides a package that includes an SSH binary. You can start the KOReader SSH server via NickelMenu. ********************************** IF RUNNING FROM KOREADER TERMINAL: # elinks IF RUNNING FROM A TELNET/SSH CLIENT CONNECTION: # cd /mnt/onboard/.adds/koreader/ # export LD_LIBRARY_PATH=/mnt/onboard/.adds/koreader/libs/ # echo $LD_LIBRARY_PATH # ./scripts/elinks You then enter '.' to see current working directory, or enter a web address (just keep pressing return if you get SSL errors). Up and Down arrows to traverse the links. Left and Right arrows to follow link or go back. Space and 'b' to page forward and back. '[' and ']' to go left and right. Enter to edit a text field, 'd' to download link. 'a' to add a bookmark, 's' to see them, TAB to move through options. ESC followed by Down arrow and Left/Right arrows to see menus. 'g' to enter a new address, 'q' to quit. ALL THIS WORKED FOR ME, BUT I AM UNSURE IF IT IS BECAUSE OF SOMETHING I INSTALLED PREVIOUSLY! YMMVVVVVVVVVVVVVV..... *** ***ADDENDUM - NANO AND WGET*** The nano editor has only the following dependencies: Depends (2) musl* ncurses-libs And it's not much additional effort to add wget . Depends (6) libcrypto3* libidn2 libssl3* musl* pcre2 zlib* *already got these from elinks install. DOWNLOAD THE REQUIRED PACKAGES: $ wget https://dl-cdn.alpinelinux.org/alpin...ano-7.0-r0.apk $ wget https://dl-cdn.alpinelinux.org/alpin...0221119-r0.apk $ wget https://dl-cdn.alpinelinux.org/alpin...0221119-r0.apk (a dependency of ncurses-libs) $ wget https://dl-cdn.alpinelinux.org/alpin...-1.21.3-r2.apk $ wget https://dl-cdn.alpinelinux.org/alpin...2-2.3.4-r0.apk $ wget https://dl-cdn.alpinelinux.org/alpin...ing-1.1-r0.apk (a dependency of libidn2) $ wget https://dl-cdn.alpinelinux.org/alpin...2-10.42-r0.apk RUN THESE COMMANDS FROM LINUX DESKTOP: $ cd myalpine/ $ tar zxvf nano-7.0-r0.apk $ tar zxvf ncurses-libs-6.3_p20221119-r0.apk $ tar zxvf ncurses-terminfo-base-6.3_p20221119-r0.apk $ tar zxvf wget-1.21.3-r2.apk $ tar zxvf libidn2-2.3.4-r0.apk $ tar zxvf libunistring-1.1-r0.apk $ tar zxvf pcre2-10.42-r0.apk $ mv usr/bin/nano scripts/ $ mv usr/lib/libformw.so.6.3 libs/libformw.so.6 $ mv usr/lib/libmenuw.so.6.3 libs/libmenuw.so.6 $ mv usr/lib/libncursesw.so.6.3 libs/libncursesw.so.6 $ mv usr/lib/libpanelw.so.6.3 libs/libpanelw.so.6 $ mv usr/bin/wget scripts/wgets $ mv usr/lib/libidn2.so.0.3.8 libs/libidn2.so.0 $ mv usr/lib/libunistring.so.5.0.0 libs/libunistring.so.5 $ mv usr/lib/libpcre2-8.so.0.11.2 libs/libpcre2-8.so.0 $ mv usr/lib/libpcre2-posix.so.3.0.4 libs/libpcre2-posix.so.3 NOW CONNECT YOUR KOBO TO YOUR PC: Copy your nano/wgets binaries from the scripts/ folder on the PC to the /mnt/onboard/.adds/koreader/scripts/ folder on the kobo. Copy new libs from the libs/ folder on the PC to the /mnt/onboard/.adds/koreader/libs/ folder on the kobo: libformw.so.6 libmenuw.so.6 libncursesw.so.6 libpanelw.so.6 libidn2.so.0 libunistring.so.5 libpcre2-8.so.0 libpcre2-posix.so.3 Copy your etc/terminfo directory to the /etc/ directory. RUN THESE FROM KOREADER TERMINAL: # nano (Ctrl-x to exit) # /usr/bin/wget BusyBox v1.31.1.kobo (2020-04-22 11:41:43 EDT) multi-call binary. ... # wgets -V GNU Wget 1.21.3 built on linux-musleabihf. ... # wgets -O mr.html https://www.mobileread.com/forums/sh...91&postcount=3 (Ctrl-c if it hangs) # elinks mr.html (q to exit) IF RUNNING FROM A TELNET/SSH CLIENT CONNECTION: CREATE THE FILE "/korenv.sh": #!/bin/sh export PATH=/mnt/onboard/.adds/koreader/scripts:/mnt/onboard/.adds/koreader/plugins/terminal.koplugin/:$PATH export LD_LIBRARY_PATH=/mnt/onboard/.adds/koreader/libs:$LD_LIBRARY_PATH export TERM=xterm export HOME=/mnt/onboard/.adds/koreader/ cd $HOME Run the command " . ./korenv.sh" Then run the commands from above. (You will also be able to run the KOReader file manager as just "shfm", as listed here . *** TRY THE W3M BROWSER AS AN ALTERNATIVE TO ELINKS: The w3m web browser has only the following dependencies: Depends (6) gc libcrypto3* libssl3* musl* ncurses-libs* zlib* *already got these from elinks and nano installs. $ wget https://dl-cdn.alpinelinux.org/alpin...0220429-r3.apk $ wget https://dl-cdn.alpinelinux.org/alpin...c-8.2.2-r0.apk $ wget https://dl-cdn.alpinelinux.org/alpin...0220924-r4.apk (a dependency of gc) $ wget https://dl-cdn.alpinelinux.org/alpin...0220924-r4.apk (a dependency of gc) $ tar zxvf w3m-0.5.3.20220429-r3.apk $ tar zxvf gc-8.2.2-r0.apk $ tar zxvf libgcc-12.2.1_git20220924-r4.apk $ tar zxvf libstdc++-12.2.1_git20220924-r4.apk $ mv usr/bin/w3m scripts/ $ cp -r usr/lib/w3m libs/ $ mv usr/share/w3m/w3mhelp.html libs/w3m/ $ mv usr/lib/libcord.so.1.5.0 libs/libcord.so.1 $ mv usr/lib/libgc.so.1.5.1 libs/libgc.so.1 $ mv usr/lib/libgctba.so.1.5.0 libs/libgctba.so.1 $ mv usr/lib/libgcc_s.so.1 libs/libgcc_s.so.1 $ mv usr/lib/libstdc++.so.6.0.30 libs/libstdc++.so.6 NOW CONNECT YOUR KOBO TO YOUR PC: Copy your w3m binary from the scripts/ folder on the PC to the /mnt/onboard/.adds/koreader/scripts/ folder on the kobo. Copy new libs from the libs/ folder on the PC to the /mnt/onboard/.adds/koreader/libs/ folder on the kobo: w3m/ libcord.so.1 libgc.so.1 libgctba.so.1 libgcc_s.so.1 libstdc++.so.6 RUN THESE FROM KOREADER TERMINAL: # cp -r libs/w3m/ /usr/lib/ # w3m -v ('U' to open link,e.g. http://w3m.sourceforge.net/ or https://github.com/tats/w3m , 'q' to quit) ('o' to get option list Space down to Color Settings->Display with color Tab to No Enter Space down to bottom of options page Tab or Esc-Tab to OK Enter 'q' , 'y' to quit) *** When upgrading to OCP-KOReader-v2023.06 and copying libs from my old KOReader setup, KOReader would crash when opening pdf files. The crash was because of libs installed for the w3m browser. w3m libs not needed: libgcc_s.so.1 libgctba.so.1 * this lib would crash KOReader when opening pdf files * Ironically, if I don't copy those two libs to the new KOReader installation, w3m seems to work fine anyway. *** ABBREVIATED OUTPUT OF "elinks -dump libs/w3m/w3mhelp.html": Spoiler:
***ADD A COUPLE OF GAMES*** The moon-buggy arcade shooting game has only the following dependencies: Depends (2) libncursesw** musl* * Already got it from the Elinks/Nano install above. ** Already got the equivalent from the Nano install above. The ttyper typing test game has only the following dependencies: Depends (2) libgcc** musl* * Already got it from the Elinks/Nano install above. ** Already got it as a gc subdependency from the W3m install above. DOWNLOAD THE REQUIRED PACKAGES: wget https://dl-cdn.alpinelinux.org/alpin...-1.0.51-r1.apk wget https://dl-cdn.alpinelinux.org/alpin...r-1.2.0-r1.apk RUN THESE COMMANDS FROM LINUX DESKTOP: $ cd myalpine/ $ tar zxvf moon-buggy-1.0.51-r1.apk $ mv usr/bin/moon-buggy scripts/ $ tar zxvf ttyper-1.2.0-r1.apk $ mv usr/bin/ttyper scripts/ NOW CONNECT YOUR KOBO TO YOUR PC: Copy your moon-buggy/ttyper binaries from the scripts/ folder on the PC to the /mnt/onboard/.adds/koreader/scripts/ folder on the kobo. RUN THESE FROM KOREADER TERMINAL: # moon-buggy (Space to jump, 'a' to fire, 'q' to quit) # ttyper -w 5 (type any letter followed by backspace to see 5-word list, then type each word followed by a space. Slide up the right scrollbar to see score.) *** ***NOTE*** The links provided were valid at the time, and should be good for a while, especially if they are all from the same branch, i.e. 3.17 in this case. But if you download packages from the edge branch, as was the case for moon-buggy, its dependencies will keep changing as the rolling edge branch keeps updating. So at some point the provided links will be out of date, and you would have to search for the package yourself in the edge branch or the latest branch(e.g. 3.18): https://pkgs.alpinelinux.org/packages?arch=armv7 This would list the up-to-date dependencies. Then download the required binary the from the appropriate repository: https://dl-cdn.alpinelinux.org/alpine/ *** Last edited by elinkser; 09-18-2023 at 06:28 PM. Reason: nano wgets + games + w3m libs not needed + edge note |
![]() |
![]() |
![]() |
#4 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 109
Karma: 146236
Join Date: Oct 2022
Device: Kobo Clara HD
|
Fbpad
Fbpad and Inkvt
There was a framebuffer-based terminal emulator that runs on the Clara HD (you have to compile it), which you can control from your phone or PC keyboard: https://www.mobileread.com/forums/sh...d.php?t=298877 These are the build directions if you have a couple of hours to kill (binary attached for your convenience.) *** On a debian PC: koreader/koxtoolchain https://github.com/koreader/koxtoolchain $ git clone https://github.com/koreader/koxtoolchain.git $ cd koxtoolchain/ $ sudo apt-get install build-essential autoconf automake bison flex gawk libtool libtool-bin libncurses-dev curl file git gperf help2man texinfo unzip wget $ ./gen-tc.sh kobo (2 hours build time on an Acer Chromebook 11 converted to an MX Linux workstation) $ cd .. *** $ mkdir fbpad-build $ cd fbpad-build/ JulianDroske/fbpads https://github.com/JulianDroske/fbpads forked from aligrudi/fbpad $ wget https://github.com/JulianDroske/fbpa...ads/master.zip $ unzip fbpads-master.zip $ cd fbpads-master/ $ make $ cd fbpad_mkfn/ $ make $ nano -l gen.sh 5 OP="-h34 -w19" 6 SZ="18h135v135" 7 # OP="-h26 -w14" 8 # SZ="18h100v100" $ ./gen.sh $ cd .. $ cd .. *** NiLuJe/FBInk https://github.com/NiLuJe/FBInk/releases $ wget https://github.com/NiLuJe/FBInk/rele...v1.25.0.tar.xz $ tar xJf FBInk-v1.25.0.tar.xz $ cd FBInk-v1.25.0/ $ source ~/koxtoolchain/refs/x-compile.sh kobo env bare $ make static stripped $ cd .. ddvk / fbpad-eink forked from kisonecat/fbpad-eink https://github.com/ddvk/fbpad-eink $ wget https://github.com/ddvk/fbpad-eink/a...ads/master.zip $ unzip fbpad-eink-master.zip $ cd fbpad-eink-master/ $ cp -r ../FBInk-v1.25.0/Release FBInk/ $ cp ../FBInk-v1.25.0/fbink.h FBInk/ $ cp ../fbpads-master/fbpad_mkfn/ar.tf fonts/ $ cp ../fbpads-master/fbpad_mkfn/ai.tf fonts/ $ cp ../fbpads-master/fbpad_mkfn/ab.tf fonts/ $ nano -l conf.h 17 typedef int fbval_t; ... 20 #define FR "ab.tf" 21 #define FI "ab.tf" 22 #define FB "ab.tf" $ nano -l Makefile 3 CC := arm-kobo-linux-gnueabihf-gcc ... 10 xxd -i fonts/ab.tf > font.h $ nano -l font.c 40 memcpy(&head, fonts_ab_tf, sizeof(head)); ... 46 font->glyphs = (int*)(fonts_ab_tf + sizeof(head)); 47 font->data =(char*) (fonts_ab_tf + sizeof(head) + font->n * sizeof(int)); $ xxd -i fonts/ab.tf > font.h $ make $ file fbpad fbpad: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 2.6.33, with debug_info, not stripped $ cd .. *** Copy the fbpad binary to the /mnt/onboard/.adds/koreader/scripts/ directory on your Kobo. On a ssh session to your Kobo (from phone or PC): $ ssh root@192.168.2.2 -p 2222 # . /korenv.sh # fbpad /bin/sh # pwd Works in landscape too. (Try elinks if you have good eyesight.)UPDATE- Fixed font size - now very readable. Hit the lower right corner of the screen and the nickel menu comes up. Ctl-Alt-q to quit If that doesn't work, try "pkill fbpad". *** How about let's change the default elinks keybindings to allow normal use of arrow keys: The hard way (see below for the easier way): In elinks, press 'k' to bring up Keybinding manager. Press Space to expand [+]- Main mapping. Use Right arrow to move focus to Delete tab. Use Down arrow to scroll to and delete the following: [-]- Move to the next frame: Tab [-]- Move to the previous frame: Shift-Tab [-]- Return to the previous document in history: Left [-]- Go forward in history: u [-]- Follow the current link: Right [-]- Follow the current link, forcing reload...: Ctrl-Right [-]- Open a lua Console: , [-]- Move to the next link: Down [-]- Move to the previous link: Up [-]- Move downwards by a page: Ctrl-F [-]- Move upwards by a page: Ctrl-B [-]- Search link text by typing ahead: # [-]- Toggle displaying of links numbers: . Use Right arrow to move focus to Save tab. Save and Close. Press 'k' to bring up Keybinding manager again. Press Space to expand [+]- Main mapping, or Up arrow to scroll to the top if already expanded. Use Left/Right arrow to focus on Add tab. Use Down arrow to scroll to and add the following: [-]- Move to the next frame: Ctrl-f [-]- Move to the previous frame: Ctrl-b [-]- Return to the previous document in history: , [-]- Go forward in history: . [-]- Show information about current link: u [-]- Open a lua Console: Alt-l [-]- Move cursor down: Down [-]- Move cursor left: Left [-]- Move cursor right: Right [-]- Move cursor up: Up [-]- Move to the next link: Tab [-]- Move to the previous link: Shift-Tab [-]- Toggle displaying of links numbers: # Use Right arrow to move focus to Save tab. Save and Close. The easier way: Or you could just append to the end of the config file: $ vi .elinks/elinks.conf Code:
################################## # Automatically saved keybindings # bind "main" "Ctrl-F" = "frame-next" bind "main" "Ctrl-B" = "frame-prev" bind "main" "," = "history-move-back" bind "main" "." = "history-move-forward" bind "main" "u" = "link-info" bind "main" "Alt-l" = "lua-console" bind "main" "Down" = "move-cursor-down" bind "main" "Left" = "move-cursor-left" bind "main" "Right" = "move-cursor-right" bind "main" "Up" = "move-cursor-up" bind "main" "Tab" = "move-link-next" bind "main" "Shift-Tab" = "move-link-prev" bind "main" "#" = "toggle-numbered-links" bind "main" "Ctrl-Right" = "none" So the new way of navigating in elinks would be: On startup, enter '.' to see current working directory, or enter a web address. Tab and Shift-Tab to traverse the links. Enter to follow link or '.' and ',' to go forward and back. Space and 'b' to page forward and back. '[' and ']' to go left and right. Enter to edit a text field, 'd' to download link. 'a' to add a bookmark, 's' to see them, TAB to move through options. ESC followed by Down arrow and Left/Right arrows to see menus. 'g' to enter a new address, 'q' to quit. Main difference being now able to move around the page with arrows keys. Old Down/Up link travelling replaced by Tab/Shift-Tab, and old Left/Right history traversing replaced by ','/'.'. *** Also get rid of the colors in the ls command by appending this to the /korenv.sh file: # vi /korenv.sh Code:
#!/bin/sh export PATH=$PATH:/mnt/onboard/.adds/koreader/scripts:/mnt/onboard/.adds/koreader/plugins/terminal.k export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/mnt/onboard/.adds/koreader/libs export TERM=xterm export HOME=/mnt/onboard/.adds/koreader/ cd $HOME alias ls='ls --color=never' But it seems you have to run it again after running fbpad. *** To get rid of the colors in the w3m browser: In w3m, normally press 'o' to bring up the Option Setting Panel. Scroll down to the second group, Color Settings. Put the cursor on the first entry: Display with color. Tab to the ()NO option and press enter. Scroll to the end of the section, tab to the [OK], and press enter. Or just edit the config file: $ nano -l .w3m/config 38 color 0 But w3m doesn't handle very well fbpad with large font/low number of columns. Or at all, as you can see with the small-font "fbpads" that I reuploaded. Note: the "fbpads" I uploaded means "fbpad with Small font", not because it is the above JulianDroske/fbpads that I exploited earlier in the post for its font setup. Sorry for any confusion. *** Networking note: In Quitting Telnet Habit , I said that I wanted to quit telnet and turn off devmode ( Go to the Discover tab and search the store for "devmodeoff"). meaning I lost the "ForceWifiOn=true" option in [DeveloperSettings] in the /mnt/onboard/.kobo/Kobo/Kobo eReader.conf file. Unfortunately I now find the WiFi connection cutting out. Others have said leaving the Wifi applet dialog open helps, so I am trying that. *** Here's one with keyboard: NiLuJe/inkvt forked from llandsmeer/inkvt https://github.com/NiLuJe/inkvt $ mkdir inkpad-build $ cd inkpad-build/ $ wget http://http.us.debian.org/debian/poo....1.1-1_all.deb $ sudo dpkg -i libcxxopts-dev_3.1.1-1_all.deb OR $ sudo apt install libcxxopts-dev $ source ~/koxtoolchain/refs/x-compile.sh kobo env bare $ cp ../fbpad-build/FBInk-v1.25.0.tar.xz . $ tar xJf FBInk-v1.25.0.tar.xz $ wget https://github.com/NiLuJe/inkvt/arch...ads/master.zip $ unzip master.zip $ mv master.zip inkvt-master.zip $ cd inkvt-master/ $ mv ../FBInk-v1.25.0/* FBInk/ $ mkdir cxxopts/include $ cp /usr/include/cxxopts.hpp cxxopts/include/ $ make release Extract InkVT-.zip to Kobo. InkVT erminal comes up, elinks working great, until screen froze. Update: Crashed my device, and somehow an update was triggered even though SideloadedMode=true. Note developer's warning on inkVT github page: Warning: this project is very experimental! It might brick your device. Only install this if you know what you are doing. Happy with just fbpad for now. Last edited by elinkser; 08-05-2023 at 02:33 PM. Reason: UPDATE- Fixed font size - fbpad big font, fbpads small, inkvt |
![]() |
![]() |
![]() |
#5 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 109
Karma: 146236
Join Date: Oct 2022
Device: Kobo Clara HD
|
Fbpad & USB
It seems there is somewhat flaky support for USB keyboard for fbpad on the Kobo, if you have some productive time to fritter away...
* requires USB host support: https://www.mobileread.com/forums/sh...d.php?t=340418 DOWNLOAD THE AGETTY PACKAGE: $ cd myalpine/ $ wget https://dl-cdn.alpinelinux.org/alpin...-2.38.1-r1.apk RUN THESE COMMANDS FROM LINUX DESKTOP: $ tar zxvf agetty-2.38.1-r1.apk $ mv sbin/agetty scripts/ NOW CONNECT YOUR KOBO TO YOUR PC: Copy your agetty binary from the scripts/ folder on the PC to the sbin/ folder on the kobo. Edit system file on your Kobo at your own risk (may blow up your device - just kidding, but type carefully) : EDIT /sbin/kobo_getty.sh Code:
#!/bin/sh [ -e /dev/ttymxc0 ] && /sbin/getty -L ttymxc0 115200 vt100 & [ -e /dev/ttyS0 ] && /sbin/getty -L ttyS0 0 vt100 & [ -e /dev/tty1 ] && /sbin/agetty -s 38400 -t 600 tty1 vt100 If I may paraphrase NiLuJe, "Here Be Dragons", where "Dragons" be a metaphor for messing up core system functionality possibly leading to failure to startup or connect, or even mysterious application malfunctions that manifest later on. These system files were put there by folks with comprehensive system level understanding, to be modified by folks who have invested many person-hours code-grokking/reverse engineering to achieve comparable understanding. Since I am neither, what is my excuse? Well on my Clara HD the first two lines are exactly the same except I added the "&" at the end. I then added the third line which I have researched the meaning of. Also I have multiple backups and contingency plans for connecting to and/or re-establishing my Clara. Also, it only cost 99 US$, is not used for work, and contains no important data. So non-expert readers, please make your own risk assessment. Edit NickelMenu config file: EDIT /mnt/onboard/.adds/nm/config.txt Code:
menu_item :main :fbpad :cmd_spawn :quiet:/mnt/onboard/.adds/koreader/scripts/fbpad /bin/sh 0</dev/tty1 chain_success :dbg_toast :Started fbpad chain_failure :dbg_toast :Error menu_item :main :Stop fbpad :cmd_spawn :quiet:/usr/bin/pkill fbpad chain_success :dbg_toast :Stopped fbpad chain_failure :dbg_toast :Error Power off your Kobo. When you restart it, set USB host mode, plug in your powered USB connected keyboard, run fbpad from NickelMenu, and type (may stall). ***** CORRECTION FOR MORE STABLE OPERATION: DO NOT EDIT /sbin/kobo_getty.sh. RETURN IT TO ORIGINAL STATE, e.g.: Code:
#!/bin/sh [ -e /dev/ttymxc0 ] && /sbin/getty -L ttymxc0 115200 vt100 [ -e /dev/ttyS0 ] && /sbin/getty -L ttyS0 0 vt100 #[ -e /dev/tty1 ] && /sbin/agetty -s 38400 -t 600 tty1 vt100 INSTEAD EDIT /etc/inittab to add the agetty line only: Code:
::sysinit:/etc/init.d/rcS ::respawn:/sbin/kobo_getty.sh ::once:/sbin/agetty -s 38400 -t 600 tty1 vt100 ::ctrlaltdel:/sbin/reboot ::shutdown:/etc/init.d/rcK ::restart:/sbin/init ***UPDATE*** See POST #7 for a better way of doing this. *** Edit NickelMenu config file to add Stop agetty command: EDIT /mnt/onboard/.adds/nm/config.txt Code:
menu_item :main :fbpad :cmd_spawn :quiet:/mnt/onboard/.adds/koreader/scripts/fbpad /bin/sh 0</dev/tty1 chain_success :dbg_toast :Started fbpad chain_failure :dbg_toast :Error menu_item :main :Stop fbpad :cmd_spawn :quiet:/usr/bin/pkill fbpad chain_success :dbg_toast :Stopped fbpad chain_failure :dbg_toast :Error menu_item :main :Stop agetty :cmd_spawn :quiet:/usr/bin/pkill agetty chain_success :dbg_toast :Stopped agetty chain_failure :dbg_toast :Error Power off your Kobo. When you restart it, set USB host mode, plug in your powered USB connected keyboard, run Stop agetty, then fbpad from NickelMenu, and type (shouldn't stall). Last edited by elinkser; 09-15-2023 at 09:24 PM. Reason: risk notice, cd, corrected stability,better hack |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 109
Karma: 146236
Join Date: Oct 2022
Device: Kobo Clara HD
|
OSCREEN KEYBOARD
MAKING AN ONSCREEN KEYBOARD FOR OUR TERMINAL:
Fbkeyboard is a framebuffer keyboard that we can port to Kobo's fbink library, following the fbpad-eink example. $ mkdir fbkeyboard-build $ cd fbkeyboard-build/ *** First we build fbpad as in the previous post, except we leave some rows empty at the bottom of the screen for the keyboard. Assuming you have already built KOReader's koxtoolchain, NiLuJe's FBInk library, and Aligrudi/Droske's fbpads as before: $ source ~/koxtoolchain/refs/x-compile.sh kobo env bare $ unzip fbpad-eink-master.zip $ cd fbpad-eink-master/ $ cp -r ../FBInk-v1.25.0/Release FBInk/ $ cp ../FBInk-v1.25.0/fbink.h FBInk/ (First make fbpadkbS, the small font version of fbpad for onscreen keyboard.) $ nano -l conf.h Code:
17 typedef int fbval_t; Code:
3 CC := arm-kobo-linux-gnueabihf-gcc 4 all: fbpadkbS ... 11 fbpadkbS: fbpad.o term.o pad.o draw.o font.o isdw.o scrsnap.o FBInk/Release/libfbink.a ... 15 rm -f *.o fbpadkbS Code:
25 rows = fb_rows() * 29 / 51 / fnrows; Copy the fbpadkbS binary to the /mnt/onboard/.adds/koreader/scripts/ folder on your Kobo. (Now make fbpadkb, the large font version of fbpad for onscreen keyboard.) $ cp ../fbpads-master/fbpad_mkfn/ar.tf fonts/ $ cp ../fbpads-master/fbpad_mkfn/ai.tf fonts/ $ cp ../fbpads-master/fbpad_mkfn/ab.tf fonts/ $ nano -l conf.h Code:
20 #define FR "ab.tf" 21 #define FI "ab.tf" 22 #define FB "ab.tf" Code:
4 all: fbpadkb 10 xxd -i fonts/ab.tf > font.h 11 fbpadkb: fbpad.o term.o pad.o draw.o font.o isdw.o scrsnap.o FBInk/Release/libfbink.a ... 15 rm -f *.o fbpadkb Code:
40 memcpy(&head, fonts_ab_tf, sizeof(head)); ... 46 font->glyphs = (int*)(fonts_ab_tf + sizeof(head)); 47 font->data =(char*) (fonts_ab_tf + sizeof(head) + font->n * sizeof(int)); $ nano -l pad.c Code:
25 rows = fb_rows() * 25 / 42 / fnrows; Copy the fbpadkb binary to the /mnt/onboard/.adds/koreader/scripts/ folder on your Kobo. $ cd .. Add the following entries to /mnt/onboard/.adds/nm/config.txt: Code:
... menu_item :main :fbpadkb :cmd_spawn :quiet:/mnt/onboard/.adds/koreader/scripts/fbpadkb /bin/sh 0</dev/tty1 chain_success :dbg_toast :Started fbpadkb chain_failure :dbg_toast :Error menu_item :main :Stop fbpadkb :cmd_spawn :quiet:/usr/bin/pkill fbpadkb chain_success :dbg_toast :Stopped fbpadkb chain_failure :dbg_toast :Error ... *** Freetype is a dependency of Fbkeyboard: Freetype https://freetype.org/download.html Download from: https://sourceforge.net/projects/fre...etype2/2.13.1/ $ tar zxvf freetype-2.13.1.tar.gz $ cd freetype-2.13.1/ $ ./configure --host=arm-kobo-linux-gnueabihf $ make $ cd .. *** bakonyiferenc/fbkeyboard forked from julianwi/fbkeyboard https://github.com/bakonyiferenc/fbkeyboard $ wget https://github.com/bakonyiferenc/fbk...ads/master.zip $ mv master.zip fbkeyboard-master.zip $ unzip fbkeyboard-master.zip $ cd fbkeyboard-master/ $ nano -l fbkeyboard.c Code:
... 18 */ 19 20 #include <stdlib.h> 21 #include <signal.h> 22 #include <fcntl.h> 23 #include <string.h> 24 #include <unistd.h> 25 #include <dirent.h> 26 #include <errno.h> 27 #include <linux/fb.h> 28 #include <linux/input.h> 29 #include <linux/uinput.h> 30 #include <linux/vt.h> 31 #include <ft2build.h> 32 #include FT_FREETYPE_H 33 #include "conf.h" 34 #include "draw.h" 35 volatile sig_atomic_t done = 0; 36 char *font = "/mnt/onboard/.adds/koreader/fonts/noto/NotoSans-Bold.ttf"; ... 38 char *special[][7] = { 39 { "Esc", "Tab", "Up ", "Dn ", "Lt ", "Rt ", "PgD" }, ... 53 __u16 keys[][26] = { 54 { KEY_ESC, KEY_TAB, KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT, KEY_PAGEDOWN }, ...... 88 FT_Face face; 89 int advance; // offset to the next glyph 90 int fduinput; 91 struct input_event ie; 92 int oldrow = 0, oldpressed = 0; 93 struct timeval oldstamp, newstamp, diffstamp; 94 int theight; // of touchscreen 95 int twidth; // of touchscreen 96 int trowh; // heigth of one keyboard row on touchscreen 97 98 void fill_rect(int x, int y, int w, int h, int color) ... 299 void show_fbkeyboard(int fbfd) 300 { 301 switch (rotate) { 302 case FB_ROTATE_UR: 303 lseek(fbfd, fblinelength * (fbheight - height * 6), SEEK_SET); 304 write(fbfd, buf, buflen); 305 keyb_refresh(fbfd, fbheight - height * 6, 0, width, fbheight); 306 break; 307 case FB_ROTATE_UD: 308 lseek(fbfd, 0, SEEK_SET); 309 write(fbfd, buf, buflen); 310 keyb_refresh(fbfd, 0, 0, width, height * 5); 311 break; 312 case FB_ROTATE_CW: 313 for (int i = 0; i < width; i++) { 314 lseek(fbfd, fblinelength * i, SEEK_SET); 315 write(fbfd, (int32_t *) (buf + linelength * i), linelength); 316 } 317 keyb_refresh(fbfd, 0, 0, height * 5, width); 318 break; 319 case FB_ROTATE_CCW: 320 for (int i = 0; i < width; i++) { 321 lseek(fbfd, fblinelength * i + (fbwidth - height * 5) * 4, SEEK_SET); 322 write(fbfd, (int32_t *) (buf + linelength * i), linelength); 323 } 324 keyb_refresh(fbfd, 0, fbwidth - height * 5, fbwidth, width); 325 break; 326 } 327 } 328 /* Waits for a relevant input event. Returns 0 if touched, 1 if released. */ 329 int check_input_events(int fdinput, int *x, int *y) 330 { 331 int released = 0; 332 int key = 1; 333 int absolute_x = -1, absolute_y = -1; 334 while (!done && !released && (absolute_x == -1 || absolute_y == -1)) 335 while (read(fdinput, &ie, sizeof(struct input_event)) 336 && !(ie.type == EV_SYN && ie.code == SYN_REPORT)) { 337 if (ie.type == EV_ABS) { 338 switch (ie.code) { 339 case ABS_MT_POSITION_X: 340 absolute_x = ie.value; 341 released = 0; 342 key = 0; 343 break; 344 case ABS_MT_POSITION_Y: 345 absolute_y = ie.value; 346 released = 0; 347 key = 0; 348 break; 349 case ABS_MT_TRACKING_ID: 350 if (ie.value == -1) { 351 released = 1; 352 } 353 break; 354 } 355 } ... 356 if (ie.type == EV_SYN && ie.code == SYN_MT_REPORT) { ... 357 released = 1; 358 } 359 } 360 switch (rotate) { 361 case FB_ROTATE_UR: 362 *x = 0x10000 - absolute_y * 0x10000 / theight; 363 *y = absolute_x * 0x10000 / twidth; 364 break; 365 case FB_ROTATE_UD: 366 *x = 0x10000 - absolute_x * 0x10000 / twidth; 367 *y = 0x10000 - absolute_y * 0x10000 / theight; 368 break; 369 case FB_ROTATE_CW: 370 *x = absolute_y * 0x10000 / theight; 371 *y = 0x10000 - absolute_x * 0x10000 / twidth; 372 break; 373 case FB_ROTATE_CCW: 374 *x = 0x10000 - absolute_y * 0x10000 / theight; 375 *y = absolute_x * 0x10000 / twidth; 376 break; 377 } 378 oldstamp.tv_sec = newstamp.tv_sec; 379 oldstamp.tv_usec = newstamp.tv_usec; 380 newstamp.tv_sec = ie.time.tv_sec; 381 newstamp.tv_usec = ie.time.tv_usec; 382 timersub(&newstamp,&oldstamp,&diffstamp); 383 return released; 384 } 385 /* x, y and trowh are scaled to 2^16 (e.g. min x = 0, max x = 65535) */ 386 void identify_touched_key(int x, int y, int *row, int *pressed) 387 { 388 switch ((0x10000 - y) / trowh) { 389 case 5: 390 *row = 0; // Esc, Tab, F10, etc 391 *pressed = x * 7 / 0x10000; 392 break; 393 case 4: 394 *row = 1; // q - p 395 *pressed = x * 10 / 0x10000; 396 break; 397 case 3: 398 *row = 1; // a - l 399 if (x > 0x10000 / 20 && x < 0x10000 * 19 / 20) 400 *pressed = 10 + (x * 10 - 0x10000 / 2) / 0x10000; 401 break; 402 case 2: 403 if (x < 0x10000 * 3 / 20) { 404 *row = 3; 405 *pressed = 0; // Left Shift 406 } else if (x < 0x10000 * 17 / 20) { 407 *row = 1; // z - m 408 *pressed = 19 + (x * 10 - 0x10000 * 3 / 2) / 0x10000; 409 } else { 410 *row = 3; 411 *pressed = 1; // Bcksp 412 } 413 break; 414 case 1: 415 *row = 4; 416 if (x < 0x10000 * 3 / 20) 417 *pressed = 99; // 123!@ 418 else if (x < 0x10000 * 5 / 20) 419 *pressed = 0; // Left Alt 420 else if (x < 0x10000 * 15 / 20) 421 *pressed = 1; // Space 422 else if (x < 0x10000 * 17 / 20) 423 *pressed = 2; // Right Ctrl 424 else 425 *pressed = 3; // Enter 426 break; 427 default: 428 *row = 5; // cursor, Enter, Home, PgDn, etc 429 *pressed = 3 * y / (0x10000 - trowh * 6); 430 *pressed *= 3; 431 *pressed += 3 * x / 0x10000; 432 break; 433 } 434 } 435 ... 489 } else { 490 send_key(keys[row][pressed]); 491 } 492 oldrow = row; 493 oldpressed = pressed; 494 } 495 /* return max of rows */ 496 int reset_window_size(int fd) ... 559 560 /* fdcons = open("/dev/tty1", O_RDWR | O_NOCTTY); 561 if (fdcons < 0) { 562 perror("Error opening /dev/tty1"); 563 exit(-1); 564 } */ 565 ... 599 600 if (fb_init(FBDEV)) { 601 fprintf(stderr, "fbkeyboard: failed to initialize the framebuffer\n"); 602 return 1; 603 } 604 if (sizeof(fbval_t) != FBM_BPP(fb_mode())) { 605 fprintf(stderr, "fbkeyboard: fbval_t does not match framebuffer depth (%d bytes$ 606 return 1; 607 } 608 609 timerclear(&oldstamp); 610 timerclear(&newstamp); 611 timerclear(&diffstamp); 612 fbfd = fb_fd(); 613 fbwidth = fb_cols(); 614 fbheight = fb_rows(); 615 fblinelength = fb_length(); 616 switch (rotate) { 617 case FB_ROTATE_UR: ... 724 725 while (!done) { 726 /* if (!ioctl(fdcons, VT_GETSTATE, &ttyinfo)) { 727 if (tty != ttyinfo.v_active) { 728 tty = ttyinfo.v_active; 729 close(fdcons); 730 fdcons = open("/dev/tty1", O_RDWR | O_NOCTTY); 731 set_window_size(fdcons); 732 resized[tty] = 1; 733 } 734 } else { 735 perror("VT_GETSTATE ioctl failed"); 736 } */ 737 738 draw_keyboard(row, pressed); 739 show_fbkeyboard(fbfd); 740 released = check_input_events(fdinput, &x, &y); 741 742 if (released) 743 identify_touched_key(x, y, &row, &pressed); 744 if (pressed != -1 && (pressed != oldpressed || (long)diffstamp.tv_usec > 50000)) 745 send_uinput_event(row, pressed); 746 pressed = -1; 747 } 748 ... 760 reset_window_size(fdcons); 761 } 762 } 763 fb_free(); 764 } 765 ... $ mkdir FBInk $ cp -r ../FBInk-v1.25.0/Release FBInk/ $ cp ../FBInk-v1.25.0/fbink.h FBInk/ $ cp ../fbpad-eink-master/draw.c . $ cp ../fbpad-eink-master/draw.h . $ cp ../fbpad-eink-master/conf.h . $ cp ../freetype-2.13.1/objs/.libs/libfreetype.so* . $ nano -l draw.c Code:
... 160 161 int fb_length(void) 162 { 163 return finfo.line_length; 164 } 165 166 void keyb_refresh(int fd, int invalid_top, int invalid_left, int invalid_right, int invalid_bot$ 167 fbink_refresh( fb_fd(), 168 invalid_top, 169 invalid_left, 170 invalid_right - invalid_left, 171 invalid_bottom - invalid_top, 172 cfg() ); 173 /* invalid_nonempty = 0; */ 174 invalid_top = invalid_bottom = invalid_left = invalid_right = 0; 175 } 176 $ nano -l draw.h Code:
19 int fb_length(void); 20 void keyb_refresh(int fd, int invalid_top, int invalid_left, int invalid_right, int invalid_bottom); $ arm-kobo-linux-gnueabihf-gcc -o fbkeyboard -I../freetype-2.13.1/include/ fbkeyboard.c draw.c libfreetype.a FBInk/Release/libfbink.a Copy the fbkeyboard binary to the /mnt/onboard/.adds/koreader/scripts/ folder on your Kobo. $ cd .. Add the following entries to /mnt/onboard/.adds/nm/config.txt: Code:
... menu_item :main :fbkeyboard :cmd_spawn :quiet:/mnt/onboard/.adds/koreader/scripts/fbkeyboard chain_success :dbg_toast :Started fbkeyboard chain_failure :dbg_toast :Error menu_item :main :Stop fbkeyboard :cmd_spawn :quiet:/usr/bin/pkill fbkeyboard chain_success :dbg_toast :Stopped fbkeyboard chain_failure :dbg_toast :Error ... From MyBooks, go to the Activity page on your Kobo (second tab from left at bottom of screen.) From NickelMenu select Stop Agetty, fbpadkb, and fbkeyboard entries. (i.e. requires that you implemented the USB keyboard hack of the previous post.) Unfortunately too slow for practical use right now. Hopefully something can be tweaked to optimize it. Can exit with Stop fbkeyboard and Stop fbpadkb entries. *** EDIT: Added arrow keys to lines 39, 40 and 54 of fbkeyboard.c: Code:
38 char *special[][7] = { 39 { "Esc", "Tab", " ^ ", " v ", " < ", " > ", ">>⇓" }, 40 { "Esc", "Tab", " ^ ", " v ", " < ", " > ", ">>⇓" }, 41 }; ... 53 __u16 keys[][26] = { 54 { KEY_ESC, KEY_TAB, KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT, KEY_PAGEDOWN }, ... EDIT: Added non-blocking IO to fbkeyboard.c to get faster response: Code:
... 334 while (!done && !released && (absolute_x == -1 || absolute_y == -1)) 335 while ((read(fdinput, &ie, sizeof(struct input_event)) > 0) 336 /* && !(ie.type == EV_SYN && ie.code == SYN_REPORT) */ ) { 337 if (ie.type == EV_ABS) { 338 switch (ie.code) { 339 case ABS_MT_POSITION_X: 340 absolute_x = ie.value; 341 released = 0; 342 key = 0; 343 break; 344 case ABS_MT_POSITION_Y: 345 absolute_y = ie.value; 346 released = 0; 347 key = 0; 348 break; 349 case ABS_MT_TRACKING_ID: 350 if (ie.value == -1) { 351 released = 1; 352 } 353 break; 354 } 355 } 356 if (ie.type == EV_SYN && ie.code == SYN_REPORT) { 357 released = 1; 358 } 359 } 360 switch (rotate) { ''' 659 while ((dptr = readdir(inputdevs))) { 660 if ((fdinput = 661 openat(dirfd(inputdevs), dptr->d_name, 662 O_RDONLY | O_NONBLOCK)) != -1 663 && ioctl(fdinput, EVIOCGBIT(0, sizeof(key)), 664 &key) != -1 && key >> EV_ABS & 1) 665 break; ... 742 if (released) 743 identify_touched_key(x, y, &row, &pressed); 744 if (pressed != -1 && (pressed != oldpressed || (long)diffstamp.tv_usec > 200000)) 745 send_uinput_event(row, pressed); 746 pressed = -1; 747 usleep(50000); 748 } 749 int i; ... Unicode Character 21d3 (PageDown arrow on line 39) was entered while holding Ctrl-Sh-u. https://en.wikipedia.org/wiki/Arrow_(symbol) *** This code is probably in need of cleanup. Feel free to jump in! *** ***UPDATE*** See POST #7 - Need WiFi ON (or USB networking) to avoid freezing. *** Last edited by elinkser; 09-18-2023 at 05:22 PM. Reason: EDIT: Added arrow keys,nonblock,need wifi on |
![]() |
![]() |
![]() |
#7 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 109
Karma: 146236
Join Date: Oct 2022
Device: Kobo Clara HD
|
SAVING SPACE IN NICKELMENU WITH "SUBMENUS" USING NICKELDBUS
***
SAVING SPACE IN NICKELMENU WITH "SUBMENUS" USING NICKELDBUS Your NickelMenu might be getting crowded if you have added all the following entries: Code:
menu_item :main :stop agetty+fbpad+fbkeyboard :cmd_spawn :quiet:/usr/bin/pkill agetty chain_success :cmd_spawn :quiet :/usr/bin/pkill fbpad chain_failure :cmd_spawn :quiet :/usr/bin/pkill fbpad chain_success :cmd_spawn :quiet :/usr/bin/pkill fbkeyboard chain_failure :cmd_spawn :quiet :/usr/bin/pkill fbkeyboard menu_item :main :fbpadkb+fbkeyboard :cmd_spawn :quiet :/mnt/onboard/.adds/koreader/scripts/fbpadkb /bin/sh 0</dev/tty1 chain_success :cmd_spawn :quiet :/mnt/onboard/.adds/koreader/scripts/fbkeyboard chain_success :dbg_toast :Started fbpadkb and fbkeyboard chain_failure :dbg_toast :Error starting fbpadkb or fbkeyboard menu_item :main :fbpadkbS+fbkeyboard :cmd_spawn :quiet :/mnt/onboard/.adds/koreader/scripts/fbpadkbS /bin/sh 0</dev/tty1 chain_success :cmd_spawn :quiet :/mnt/onboard/.adds/koreader/scripts/fbkeyboard chain_success :dbg_toast :Started fbpadkbS and fbkeyboard chain_failure :dbg_toast :Error starting fbpadkbS or fbkeyboard menu_item :main :fbpad (toggle):cmd_output :500:quiet :/usr/bin/pkill -f "fbpad" chain_success:skip:4 chain_failure :cmd_spawn :quiet :/mnt/onboard/.adds/koreader/scripts/fbpad /bin/sh 0</dev/tty1 chain_success :dbg_toast :Started fbpad chain_failure :dbg_toast :Error starting fbpad chain_always:skip:-1 chain_success :dbg_toast :Stopped fbpad menu_item :main :fbpadS (toggle):cmd_output :500:quiet :/usr/bin/pkill -f "fbpadS" chain_success:skip:4 chain_failure :cmd_spawn :quiet :/mnt/onboard/.adds/koreader/scripts/fbpadS /bin/sh 0</dev/tty1 chain_success :dbg_toast :Started fbpadS chain_failure :dbg_toast :Error starting fbpadS chain_always:skip:-1 chain_success :dbg_toast :Stopped fbpadS menu_item :main :fbkeyboard (toggle):cmd_output :500:quiet :/usr/bin/pkill fbkeyboard chain_success:skip:4 chain_failure :cmd_spawn :quiet :/mnt/onboard/.adds/koreader/scripts/fbkeyboard chain_success :dbg_toast :Started fbkeyboard chain_failure :dbg_toast :Error starting fbkeyboard chain_always:skip:-1 chain_success :dbg_toast :Stopped fbkeyboard *** But NickelDBus allows us to condense everything to a single NickelMenu entry (i.e. also need NickelDBus installed): Code:
menu_item :main :fbmenu :cmd_spawn :quiet:exec /mnt/onboard/.adds/koreader/scripts/fbmenu.sh chain_success :dbg_toast :Started fbmenu chain_failure :dbg_toast :Error Also create script /mnt/onboard/.adds/koreader/scripts/fbmenu.sh: Code:
#!/bin/sh # fbmenu - fbpad and fbkeyboard selection menu num=0 qndb -m dlgConfirmCreate true qndb -m dlgConfirmSetTitle "1-Stop agetty+fb(all); 2-fbpadkb; 3-fbpadkbS; 4-fbpad; 5-fbpadS; 6-fbkeyboard; Select option (1-6):" qndb -m dlgConfirmSetLEPlaceholder "1" qndb -m dlgConfirmShow result=$(qndb -s dlgConfirmTextInput) textIn=$(echo $result | sed 's/dlgConfirmTextInput //') num=$(echo $textIn | sed 's/[^0-9]//g') num=${num:-1} if [ "$num" != "$textIn" ] then num=1 fi if [ "$num" == "1" ]; then qndb -m mwcToast 1000 "You selected 1-Stop agetty+fbpad" fbcmd="/usr/bin/pkill agetty" qndb -m mwcToast 1000 "$fbcmd" fberr=$($fbcmd 2>&1) fbcmd="/usr/bin/pkill fbpad" qndb -m mwcToast 1000 "$fbcmd" fberr=$($fbcmd 2>&1) fbcmd="/usr/bin/pkill fbkeyboard" qndb -m mwcToast 1000 "$fbcmd" fberr=$($fbcmd 2>&1) elif [ "$num" == "2" ]; then qndb -m mwcToast 1000 "You selected 2-fbpadkb" fbcmd="/mnt/onboard/.adds/koreader/scripts/fbkeyboard" qndb -m mwcToast 1000 "$fbcmd" fberr=$($fbcmd 2>&1) & fbcmd="eval /mnt/onboard/.adds/koreader/scripts/fbpadkb /bin/sh 0</dev/tty1" qndb -m mwcToast 1000 "$fbcmd" fberr=$($fbcmd 2>&1) elif [ "$num" == "3" ]; then qndb -m mwcToast 1000 "You selected 3-fbpadkbS" fbcmd="/mnt/onboard/.adds/koreader/scripts/fbkeyboard" qndb -m mwcToast 1000 "$fbcmd" fberr=$($fbcmd 2>&1) & fbcmd="eval /mnt/onboard/.adds/koreader/scripts/fbpadkbS /bin/sh 0</dev/tty1" qndb -m mwcToast 1000 "$fbcmd" fberr=$($fbcmd 2>&1) elif [ "$num" == "4" ]; then qndb -m mwcToast 1000 "You selected 4-fbpad" fbcmd="eval /mnt/onboard/.adds/koreader/scripts/fbpad /bin/sh 0</dev/tty1" qndb -m mwcToast 1000 "$fbcmd" fberr=$($fbcmd 2>&1) elif [ "$num" == "5" ]; then qndb -m mwcToast 1000 "You selected 5-fbpadS" fbcmd="eval /mnt/onboard/.adds/koreader/scripts/fbpadS /bin/sh 0</dev/tty1" qndb -m mwcToast 1000 "$fbcmd" fberr=$($fbcmd 2>&1) elif [ "$num" == "6" ]; then qndb -m mwcToast 1000 "You selected 6-fbkeyboard" fbcmd="/mnt/onboard/.adds/koreader/scripts/fbkeyboard" qndb -m mwcToast 1000 "$fbcmd" fberr=$($fbcmd 2>&1) else qndb -m mwcToast 1000 "You selected an invalid option" fi qndb -m mwcToast 1000 "${fberr:-"Bye!"}" *** A NEW HACK TO AVOID MESSING WITH SYSTEM FILES LIKE A PRO: * While messing around with an rmkit install, I saw how they avoided messing with system files like we did in POST #5 above: Return your /etc/inittab to to the way it was (i.e. remove the "agetty" line you added). Instead create the following file: /etc/udev/rules.d/90-fbpad.rules Code:
# : 90-fbpad.rules 2015-01-10 23:58:00Z NiLuJe $ # Runs early at boot... (onboard *might* be mounted at that point) KERNEL=="loop0", RUN+="/sbin/agetty -s 38400 tty1 vt100" It would be nice if we could also kill agetty automatically with the following file, but I tried it and that one doesn't work: /etc/udev/rules.d/91-fbpad.rules Code:
# : 91-fbpad.rules 2015-01-10 23:58:00Z NiLuJe $ # Runs early at boot... (onboard *might* be mounted at that point) KERNEL=="loop0", RUN+="/usr/bin/pkill agetty" *** IMPORTANT NOTE: ON MY KOBO, EITHER USB OR WIFI NETWORKING (WHETHER CONNECTED TO HOTSPOT OR NOT) HAD TO BE ENABLED OR DEVICE FREEZES. WHO KNOWS WHY? SORRY FOR ANY FRUSTRATION - I HAD DONE MANY SUCCESFUL TESTS NOT REALIZING THAT ENABLING WIFI WAS RELEVANT! **** Last edited by elinkser; 09-16-2023 at 07:27 PM. Reason: NEEDS USB OR WIFI NETWORKING ENABLED! |
![]() |
![]() |
![]() |
#8 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 109
Karma: 146236
Join Date: Oct 2022
Device: Kobo Clara HD
|
ADD A CHESS GAME FOR THE TERMINAL
***ADD A CHESS GAME FOR THE TERMINAL***
Here's a chess app to stress test your fbpadkb, and have a little fun at the same time! The gnuchess game has only the following dependencies: Depends (3) libgcc** libintl musl* * Already got it from the Elinks/Nano install above (POST #3 - also got the /korenv.sh script.) ** Do not install libgcc since it would crash OCP-KOReader-v2023.06 when opening pdf files. Fortunately, gnuchess runs fine without it! RUN THESE COMMANDS FROM LINUX DESKTOP: $ cd myalpine/ DOWNLOAD THE REQUIRED PACKAGES: $ wget https://dl-cdn.alpinelinux.org/alpin...s-6.2.9-r1.apk $ wget https://dl-cdn.alpinelinux.org/alpin...-0.21.1-r1.apk $ tar zxvf gnuchess-6.2.9-r1.apk $ tar zxvf libintl-0.21.1-r1.apk $ mv usr/bin/gnuchess scripts/ $ mv usr/lib/libintl.so.8.3.0 libs/libintl.so.8 NOW CONNECT YOUR KOBO TO YOUR PC: Copy your gnuchess binary from the scripts/ folder on the PC to the /mnt/onboard/.adds/koreader/scripts/ folder on the kobo. Copy new lib from the libs/ folder on the PC to the /mnt/onboard/.adds/koreader/libs/ folder on the kobo: libintl.so.8 Copy the usr/share/gnuchess folder on the PC to the /usr/share/ folder on the kobo: PLAY CHESS FROM fbpadkb TERMINAL: # . /korenv.sh # gnuchess -e GNU Chess 6.2.9 Copyright (C) 2021 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. White (1) : ENTER YOUR MOVE, E.G.: White (1) : e2e4 1. e2e4 black KQkq e3 r n b q k b n r p p p p p p p p . . . . . . . . . . . . . . . . . . . . P . . . . . . . . . . . P P P P . P P P R N B Q K B N R Thinking... white KQkq d6 r n b q k b n r p p p . p p p p . . . . . . . . . . . p . . . . . . . . P . . . . . . . . . . . P P P P . P P P R N B Q K B N R My move is : d5 White (2) : ENTER YOUR NEXT MOVE, E.G.: White (2) : e4d5 2. e4d5 black KQkq r n b q k b n r p p p . p p p p . . . . . . . . . . . P . . . . . . . . . . . . . . . . . . . . P P P P . P P P R N B Q K B N R Thinking... white KQkq r n b q k b . r p p p . p p p p . . . . . n . . . . . P . . . . . . . . . . . . . . . . . . . . P P P P . P P P R N B Q K B N R My move is : Nf6 SAVE YOUR GAME AND QUIT: White (3) : pgnsave game1.pgn White (3) : quit # PLAY AGAIN: # gnuchess -e GNU Chess 6.2.9 Copyright (C) 2021 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. White (1) : LOAD YOUR GAME AND QUIT: White (1) : pgnload game1.pgn white KQkq r n b q k b . r p p p . p p p p . . . . . n . . . . . P . . . . . . . . . . . . . . . . . . . . P P P P . P P P R N B Q K B N R White (1) : quit # With a little command-line labor you can install a GUI chess app in a graphical chroot, thanks to NiMa et al: https://www.mobileread.com/forums/sh...d.php?t=336210 Updated setup instructions starting from: https://www.mobileread.com/forums/sh...4&postcount=53 Then just: # apk add xboard # xboard TIPS FOR GETTING STARTED WITH GRAPHICAL CHROOT: 1) Start with the simpler non-graphical version of the chroot: https://www.mobileread.com/forums/sh...d.php?t=336175 (You may find a script like the one in section 6 of this comment helpful.): https://www.mobileread.com/forums/sh...1&postcount=46 2) Try this site to get the tldr description of a Linux command e.g. the chroot command: https://html.duckduckgo.com/html/?q=tldr+chroot (You can change the "chroot" to some other command, e.g. "pkill"): https://html.duckduckgo.com/html/?q=tldr+pkill Last edited by elinkser; 09-19-2023 at 02:01 PM. Reason: chroot tips |
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
PW4 Terminal or SSH through experimental browser | SirMassive | Kindle Developer's Corner | 7 | 03-30-2021 08:51 PM |
Web Browser and BookWalker web viewer | chronoreverse | Amazon Kindle | 0 | 02-06-2019 01:44 PM |
Cannot access Calibre-Web via Kobo web browser | chakattack | Server | 14 | 08-19-2018 07:51 PM |
Kindle Fire Web Browser will likely allow for web based games. | sirmaru | Kindle Fire | 10 | 11-15-2011 02:55 PM |
merged terminal/launchpad/web server | lrizzo | Kindle Developer's Corner | 46 | 10-21-2011 05:51 PM |