View Single Post
Old 12-24-2022, 09:43 PM   #46
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
Works on Clara HD

***
These instructions worked great for the most part for my Kobo Clara HD with alpine-minirootfs-3.17.0-armv7.
***


I found I needed the following two changes.


1.FBINK-XDAMAGE NOT COMPILING:

I used instead:
git clone --recurse-submodules https://github.com/tux-linux/fbink-xdamage.git


2.ONBOARD KEYBOARD NOT DISPLAYING AT STARTUP (not consistently):
* Edit: this was resolved in post #54.
https://www.mobileread.com/forums/sh...5&postcount=54

I used svkbd-mobile-intl:
apk add svkbd


***


I did make some other changes for various reasons.


1.APPS TOO CLUNKY OR OTHER:

I substituted qterminal, qpdfview, netsurf, and tigervnc/tigervnc-client for xterm, firefox, and xvnc.
I also used a 1GB image size (dd if=/dev/zero of=/mnt/onboard/alpine.img bs=1M count=1024) which only left me with a couple of hundred MB free space.
But after compiling the fbink_xdamage binary, I saved it and the Release folder with the fbink libs.
You can delete the dev packages, firefox etc., so it fits nicely in a 1GB alpine.img file - easy to back up in case you bork it.
But see step 12 below for an even more compact and flexible backup!

2.TO NOT RELY ON DRAG AND DROP OR WINDOW RESIZING:

To get the desired placement of a keyboard in the lower third of the screen, terminal in the upper two thirds of a screen, and browser covering the whole screen, the last lines of my xorg-chroot.sh looked like this:
#DISPLAY=:0 xterm -e "/home/root/dpi.sh;sh"
DISPLAY=:0 qterminal --geometry 1400x620+20+60 &
DISPLAY=:0 netsurf --scale 150 &
#DISPLAY=:0 vncviewer -geometry 1400x960+20+60 192.168.43.9 &
DISPLAY=:0 svkbd-mobile-intl -g 1400x320+20+700 &
#DISPLAY=:0 dillo -g 1400x960+20+60 &


3.NETSURF BROWSER ELEMENTS TOO TINY:

Added file .config/netsurf/Choices:
font_size:192
accept_language:en
block_advertisements:1
send_referer:0
animate_images:0
enable_javascript:0
url_suggestion:0
window_x:20
window_y:60
window_width:1400
window_height:960
toolbar_status_size:6673
button_type:3
disable_popups:1
toolbar_items:back/history/forward/reloadstop/url_bar/copy/paste/showbookmarks/downloads/zoomplus/zoomminus/openmenu
bar_show:menu/tool

Added file .config/gtk-3.0/gtk.css:
scrollbar slider {min-width: 30px;}
default-decoration {min-height: 40px;}
default-decoration.titlebutton {min-height: 36px;}


*I couldn't figure out how to make the menu elements bigger. A workaround is to install netsurf on your desktop and familiarize yourself with the menu elements, so you can more easily recognize them on your kobo.
*** UPDATE: This is resolved in comment #51


4.TASKBAR TOO TINY:
You really need to be able to click on the taskbar to select keyboard for input, or change apps.
I modified the following line in .config/tint2/tint2rc:

# Panel
panel_items = SLCT
panel_size = 100% 60
panel_position = top center horizontal

5.MY PREFERRED FILEMANAGER MC WORKS BETTER IN BASH SHELL:
I installed bash and mc, and changed the symbolic link /bin/sh to link to /bin/bash.
Note:if using mc remotely from your desktop by telnet, you have to "export TERM=xterm" to run mc.
I added these lines to .bashrc to keep command-line history from getting cluttered by mc:

HISTCONTROL=ignoreboth
shopt -s histappend

While in X, you may prefer a GUI filemanager like pcmanfm.


6.FOR RUNNING ALPINE CHROOT FROM A KOREADER TERMINAL (WITHOUT X):
I added /mnt/onboard/.adds/koreader/scripts/chalpine.sh:

#!/bin/sh
mount /mnt/onboard/alpine.img /mnt/user
#mount -v --bind /mnt/onboard/shared /mnt/user/shared
mount -v --bind /dev /mnt/user/dev
mount -vt proc proc /mnt/user/proc
mount -vt sysfs sysfs /mnt/user/sys
cp /etc/resolv.conf /mnt/user/etc
chroot /mnt/user/ /bin/sh

So from the KOReader terminal I just run "chalpine.sh" to get into the alpine chroot without X, where I can still run elinks, etc.
I also added /mnt/onboard/.adds/koreader/scripts/chalpined.sh:

#!/bin/sh
umount /mnt/user/dev
umount /mnt/user/proc
umount /mnt/user/sys
#umount /mnt/user/shared
umount /mnt/user

So to get out, I can run
sync
poweroff
OR
sync
exit
chalpined.sh

Optionally, create directories for sharing data from in (/mnt/user/shared) and out (mnt/onboard/shared) of chroot by creating those directories and ucommenting above lines.
Also add to your xorg-boot.sh the same line i.e.:
mount -v --bind /mnt/onboard/shared /mnt/user/shared

*SECURITY NOTE*
First thing in the chroot, you should create a non-root user and give it a .config folder:

adduser myuser
cp -r /home/root/.config /home/myuser/
chown -R myuser:myuser /home/myuser/.config

Then install and configure sudo for the non-root user:
apk add sudo
Run "visudo" to edit /etc/sudoers to append these lines (don't worry if visudo says you're saving to sudoers.tmp - visudo is just doing a preliminary check before writing - you can check the edit was made by running "less /etc/sudoers") :
myuser ALL=NOPASSWD: /bin/sync #ok maybe didn't need this one
myuser ALL=NOPASSWD: /sbin/poweroff

So, when running a chroot in the KOReader terminal:
Each time you enter the chroot you switch to non-root by "su - myuser" or "/bin/login".
To become root again, you exit once, and to leave the chroot, you sync then exit a second time.
(You can check you are no longer in the chroot by running "df".)
Then unmount the chroot as before by running chalpined.sh.

And when running a chroot from X as in STEP 13 below:
You can
sync
sudo poweroff
right from the user account.

Don't get complacent about the "sync", like I did and ended up with an unreadable but undeletable file.



***
CAUTION: You know how Nickel does all that background work when you connect USB cable to desktop, click "connect", then later unmount?

Well, there may be a risk of data corruption if you had a loop mounted file, e.g. Alpine chroot.
https://www.mobileread.com/forums/sh...38&postcount=2

So better don't try this. But if you DO connect a USB cable, either exit the chroot and unmount the loop first, OR click "cancel" and use SSH/Telnet networking instead. (I have done this for months.)
***



7.FOR RUNNING ALPINE CHROOT FROM NICKEL MENU (WITH X):
First I turn on networking.
Then I set the orientation to landscape.
Then I run Xorg.
The nickel menu entries look like this (note:moved xorg-boot.sh into mnt/onboard/opt/):

menu_item :main :Xorg :cmd_spawn :quiet:exec /mnt/onboard/opt/xorg-boot.sh
chain_success :dbg_toast :Started Xorg
chain_failure :dbg_toast :Error

# Nickel_Orientation Actions
menu_item : main : Orientation - LANDSCAPE - handle above : nickel_orientation: landscape
menu_item : main : Orientation - LANDSCAPE - handle below : nickel_orientation: inverted_landscape
menu_item : main : Orientation - PORTRAIT - handle on left : nickel_orientation: inverted_portrait
menu_item : main : Orientation - PORTRAIT - handle on right : nickel_orientation: portrait
#

To leave the Xorg environment, I enter
sync
poweroff
from the qterminal.


8.FOR RUNNING EINK BROWSER ON MY KOBO REMOTELY FROM MY TABLET:
Install droidvnc_ng and einkbro on your android tablet and run them in landscape mode.
Run "vncviewer -geometry 1400x960+20+60 192.168.43.9 &" (or whatever the droidvnc address is) in a qterminal.
A tiny little window will pop up - it is for your vnc password. Just enter it and you will have a nice full screen eink browser screen, with input touch enabled on your Kobo!
(You may have to stop and restart the droidvnc for adjusting the slider to the right size setting.)
Eink browser toolbar setting can be set to include pageup and pagedown buttons.


HOWEVER...Consider the security implications of accessing a secure device (phone that you do banking/email on) from an insecure device i.e. ereader.


9.FOR RIGHT CLICK AND DRAG AND DROP:
Enter the following time delayed commands in a qterminal, then move the pointer to the right place:

xdotool sleep 2 mousemove_relative -- -60 0 click 3
(you have 2 seconds to touch up to 60 pixels to the left of where you want the right click.
The mousemove_relative -- -60 0 is to avoid the left click when you position the pointer on a link.)
xdotool sleep 2 mousedown 1 sleep 4 mouseup 1
(you have 2 seconds to touch where you want to start a drag, then 4 seconds to touch where you want to end it)
*Python programmers are welcome to add functionality to the main driver!


In the meantime, you can activate these by clicking on a taskbar icon by adding to the Launcher section of the .config/tint2/tint2rc file from above:
#-------------------------------------
# Launcher
launcher_item_app = onboard.desktop
launcher_item_app = svkbd.desktop
launcher_item_app = qterminal.desktop
launcher_item_app = netsurf.desktop
launcher_item_app = vncviewer.desktop
launcher_item_app = xdodd.desktop
launcher_item_app = xdorc.desktop

Then copy usr/share/applications/xvkbd.desktop to usr/share/applications/xdorc.desktop but edit it to: "Exec=xdotool sleep 2 mousemove_relative ---60 0 click 3"
Or to whatever the offset you want for right clicks.
And copy usr/share/applications/xvkbd.desktop to usr/share/applications/xdodd.desktop but edit it to: "Exec=xdotool sleep 2 mousedown 1 sleep 4 mouseup 1"
(Assuming you had the xvkbd apk installed - otherwise copy from the qterminal.desktop.)
Similarly create or edit the other .desktop files in /usr/share/applications/ folder.

*UPDATE: Comment #51 offers an alternative right click method, and also PgUp/PgDn using 2-finger swipes, but it only works with libinput driver as in comment #48. I have an evdev tool that is not working yet.


10.FOR NETWORKING (E.G. TELNET) OVER USB CABLE INSTEAD OF WIFI:

***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.

**********************************


See instructions at https://www.yingtongli.me/blog/2018/...elnet-usb.html
Instead of automatically enabling it, I created a nickel menu item:

menu_item :main :USB Networking on :cmd_spawn :quiet:exec /mnt/onboard/opt/usbtoeth
chain_success :dbg_toast :Started USB networking
chain_failure :dbg_toast :Error
menu_item :main :USB Networking off :cmd_spawn :quiet:exec /mnt/onboard/opt/usbtoethd
chain_success :dbg_toast :Stopped USB networking
chain_failure :dbg_toast :Error

So to connect the Kobo with my desktop over the USB cable:
1.On Kobo, select"USB Networking on" from the nickel menu.
2.Connect the USB cable between Kobo and Desktop.
3.The network applet icon on the desktop (/usr/bin/nm-applet from the network-manager-gnome package) will be a spinning progress bar, like it's trying to connect on ethernet. Click this icon and choose "disconnect".
4.On desktop terminal enter "sudo ifconfig usb0 192.168.2.1" and you will be connected.


11.FOR CLOCK AND POWER DISPLAY:
apk add tzdata
apk add xmessage
Modify the following lines in .config/tint2/tint2rc:
#-------------------------------------
# Clock
time1_format = %H:%M
#time2_format = %A %d %B
time1_timezone = EST
time1_font = NotoSans Bold 32
clock_lclick_command = xmessage -geometry 400x100+500+70 -fn -*-fixed-*-*-*-*-32-*-*-*-*-*-iso8859-* Charge Level : `cat /sys/class/power_supply/mc13892_bat/capacity`

Now you can click on the clock to get remaining battery percentage.
For timezone, use the appropriate timezone from /usr/share/zoneinfo/.
You may also have to ln -sf /usr/share/zoneinfo/EST /etc/localtime, where again, replace EST by your actual timezone.


12.MAKE A COMPACT RESIZEABLE BACKUP:
First back up the old alpine.img to your desktop.
Now run the following commands on your Kobo:
cd /mnt/onboard
mount /mnt/onboard/alpine.img /mnt/user/
df -h ; # I got 959.9M total, 446.5M used, 462.2M available on /mnt/user
cd /mnt/user
tar zcvf /mnt/onboard/alpine.tgz . ; # took 8 minutes
cd /mnt/onboard
umount /mnt/user
ls -l alpine.tgz ; # to see your newly created backup file, only 154MB
*** NEXT TWO COMMANDS OVERWRITE YOUR alpine.img file
dd if=/dev/zero of=/mnt/onboard/alpine.img bs=1M count=2048; # OPTIONAL make 2GB image
mke2fs -F /mnt/onboard/alpine.img
***
mount /mnt/onboard/alpine.img /mnt/user/
cd /mnt/user
tar zxvf /mnt/onboard/alpine.tgz . ; # took 2 minutes
df -h ; # I got 2.0G total, 446.5M used, 1.4G available on /mnt/user
cd /mnt/onboard
umount /mnt/user
Now fire up xorg from the Kobo device.
Then from the still connected desktop:
chroot /mnt/user /bin/sh
apk search -vv -d browser
apk -s add qutebrowser ; # would require 68 packages. let's try it
apk add qutebrowser
df -h ; # I got 2.0G total, 831.1M used, 1.1G available on /mnt/user, so that needed 400M!
qutebrowser --qt-flag no-sandbox ; # Got 2 blank tabs
apk del qutebrowser
df -h ; # I got 2.0G total, 447.0M used, 1.4G available on /mnt/user
apk -s add falkon ; # would require 112 packages. let's try it
apk add falkon
df -h ; # I got 2.0G total, 737.9M used, 1.1G available on /mnt/user, only 300M
export QTWEBENGINE_DISABLE_SANDBOX=1
falkon ; # I got window with address bar, tried to enter something and it crashed
apk del falkon
df -h ; # I got 2.0G total, 448.6M used, 1.4G available on /mnt/user


13.IMPROVE SECURITY BY RUNNING X APPS AS A NON-ROOT USER:
First make sure you have followed the instructions in STEP 6 above for creating a non-root user (e.g. "myuser").

Create a nickel menu item as you did in STEP 7 , except for a non-root user:
menu_item :main :User Xorg :cmd_spawn :quiet:exec /mnt/onboard/opt/uxorg-boot.sh
chain_success :dbg_toast :Started Xorg as non-root user
chain_failure :dbg_toast :Error

Copy /mnt/onboard/opt/xorg-boot.sh to /mnt/onboard/opt/uxorg-boot.sh and edit the last line to:
chroot /mnt/user /bin/sh /uxorg-chroot.sh

In the chroot, copy /xorg-chroot.sh to /uxorg-chroot.sh and replace all lines following the "echo 20..." line with:
DISPLAY=:0 sudo -u myuser openbox &
DISPLAY=:0 sudo -u myuser tint2 &
DISPLAY=:0 sudo -u myuser qterminal --geometry 1400x620+20+60 &
DISPLAY=:0 sudo -u myuser svkbd-mobile-intl -g 1400x320+20+700 &
DISPLAY=:0 sudo -u myuser netsurf --scale 150 &

You can
sync
sudo poweroff
right from the user account.

Note:Tried to install firewall "apk add ufw", but running it failed due to missing kernel module "filter" .
ufw status verbose
#Gives error: "can't initialize iptables table `filter': Table does not exist (do you need to insmod?)"
cat /proc/config.gz | gunzip | grep NETFILTER
#Gives "CONFIG_NETFILTER is not set"

Oh well, you were not planning on using the Kobo to store your bitcoins anyway, I hope.


14. USB KEYBOARD SUPPORT:


*** UPDATE - YOU CAN POSSIBLY AVOID EXTRA CONFIGURATION OF USB KEYBOARD BY USING LIBINPUT DRIVER - SEE COMMENT #48 , (2nd COMMENT AFTER THIS ONE) ***



Enable USB host support as described here.


Create a /etc/X11/xorg.conf file as follows:


Section "ServerLayout"
Identifier "Layout"
InputDevice "USB Keyboard"
InputDevice "USB Mouse"
InputDevice "Touchscreen"
EndSection

Section "ServerFlags"
Option "AutoAddDevices" "off"
EndSection

Section "InputDevice"
Identifier "USB Keyboard"
Driver "evdev"
Option "Device" "/dev/input/event2"
EndSection

Section "InputDevice"
Identifier "USB Mouse"
Driver "evdev"
Option "Device" "/dev/input/event3"
EndSection

Section "InputDevice"
Identifier "Touchscreen"
Driver "evdev"
Option "Device" "/dev/input/event1"
EndSection


*Need to also install evdev driver:
apk install xf86-input-evdev


*The first two "InputDevice" sections depend on your particular device.
(You can check with e.g. "cat /proc/bus/input/devices" and "evtest /dev/input/eventX")
The third section is supposed to be for the touchscreen but doesn't seem to affect much.
You have to plug in your device before you run X.


Current status:

Keyboard works mostly, but some keys like arrows don't seem to be recognized.
Edit:Tried a different keyboard and arrow keys work.
Even the original keyboard can be made to work temporarily with the following cludge until the correct non-cludgy solution is done, by installing xmodmap, and then subbing keys:
xmodmap -e "keysym grave = Left Left"
xmodmap -e "keycode 119 = Up Up"
You would use different keys, but you will probably find, like I did, how buggy this hack is.
*Edit: Don't use xmodmap -use xkbcomp(or something less deprecated) as described in comment after this one!


Mouse works but cursor not visible over the app widget windows.
Edit:Tried a different app - featherpad - and the cursor is visible!.
So depends on the toolkit and widget type used in the app I guess.
There are some ghosting /refresh issues, so I will see how it works out with heavier use.
Actually the ghosting is when the entire screen changes, such as if you scroll when the page is full of text.
It would be a pain to have to refresh by minimizing/maximizing by clicking on the taskbar icon every time you scroll the editor by one line.
A workaround is to scroll several lines at a time,e.g. pagedown, then just move the cursor while the page doesn't change - no ghosting!


*Even featherpad has a "dark mode" for less ghosting!
Options->Preferences->Text->Dark cOlor scheme

* Also you can set a keybinding in the openbox window manager to refresh screen:
Create user openbox directory and copy config files to it:
cd /home/root/
mkdir .config/openbox
cp /etc/xdg/openbox/*.xml .config/openbox/

Edit the rc.xml file to add key binding for rollup toggle:
nano .config/openbox/rc.xml

Modify the first lines of the "<keyboard>" section to:
<keyboard>

<keybind key="C-S-g">
<action name="ToggleShowDesktop"/>
</keybind>

(Poweroff and restart.)

Now entering "Ctl=Shift-G" twice will toggle the desktop, refreshing the editor window!
(*removed Ctl-U binding as it interferes with nano editor.)



Other options are to use nano (but they are using Ctl-U so maybe another key needed), or the white-on-black midnight commander by invoking it as "mc --nocolor" or "mc -b", "mc -bv" (equivalent of mcview file viewer), or "mc -be" (equivalent of mcedit file editor).
Note that mc responds to fullscreen touch, and from the keyboard you can sub "esc-3" for F3 (and "esc-0" for F10 exit), enter directories with "F3", pageup/pagedown with "alt-v/ctl-v" (as opposed to "ctl-y/ctl-v" in nano or "b/space" in mcview or elinks), selecting multiple files with "ctl-t", etc.
You can even highlight with the xdodd hack from section 9 above.
Also less obvious ghosting.





***SUMMARY***
XORG IS WORKING GREAT ON THE KOBO CLARA HD. Thanks to NiMa & Co. for the 'X'-mas gift
**************

Last edited by elinkser; 10-19-2023 at 10:03 AM. Reason: (*removed Ctl-U binding as it interferes with nano editor.)
elinkser is offline   Reply With Quote