Either you use the wlan connection or you can enable usb debug on your android device. I wrote a small shell script that is launched by systemd instead of launching klipperscreen directly-
#!/bin/bash
# forward local display :100 to remote display :0
adb forward tcp:6100 tcp:6000
adb shell dumpsys nfc | grep 'mScreenState=' | grep OFF_LOCKED > /dev/null 2>&1
if [ $? -lt 1 ]
then
echo "Screen is OFF and Locked. Turning screen on..."
adb shell input keyevent 26
fi
adb shell dumpsys nfc | grep 'mScreenState=' | grep ON_LOCKED> /dev/null 2>&1
if [ $? -lt 1 ]
then
echo "Screen is Locked. Unlocking..."
adb shell input keyevent 82
fi
# start xsdl
adb shell am start-activity x.org.server/.MainActivity
ret=1
timeout=0
echo -n "Waiting for x-server to be ready "
while [ $ret -gt 0 ] && [ $timeout -lt 60 ]
do
xset -display :100 -q > /dev/null 2>&1
ret=$?
timeout=$( expr $timeout + 1 )
echo -n "."
sleep 1
done
echo ""
if [ $timeout -lt 60 ]
then
DISPLAY=:100 /home/pi/.KlipperScreen-env/bin/python screen.py
exit 0
else
exit 1
fi
Hi, that is fantastic use case for my old HTC One M8. I already managed to set it up to display the interface and “move the cursor and select the options”, but can you advise how did you set XSDL app to act like actual touch screen (if you managed to do it), without a need to move the cursor by swiping on the screen? I tried to change the Mouse emulation into Touchpad mode, but “that’s not it”…
Never mind, I found the solution: in Mouse emulation setting I had to select “Desktop no emulation” - it works amazing now… Now I need to design and print a holder for the phone
Ok, first of all, make sure you have adb installed on RPi (sudo apt-get install adb). Then make sure you have developer mode enabled in your Android device and enable debugging via USB.
Then look above how @jhs modified service startup script and create the launch script. Then just restart the service - works like a dream
Hm, I have not the same case. I use my android phone with linuxdeploy, and installed klipper, moonracker and klipperscreen. And I try to run klipperscreen on display by xsdl, but I only have linux desktop… When I try to run manualy lauch_klipperscreen.sh I get:
$ ./lauch_klipperscreen.sh
* daemon not running; starting now at tcp:5037
* daemon started successfully
error: no devices/emulators found
error: no devices/emulators found
error: no devices/emulators found
error: no devices/emulators found
Waiting for x-server to be ready ....
I understand correctly that the script described @jhs is this lauch_klipperscreen.sh?
Hello! Joint efforts managed to launch KlipperScreen on android!
First you need to install linuxdeploy as described by Somekev points 1-14 inclusive, but the “Distribution suite” must be “stable” and you need to enable X11 GUI with XTerm in properties. Don’t forget to expand the image size about 4000 mb.
Hello! This is not my script.
The author of this script prefer vnc, but with X11 KlipperScreen works better.
Anyway, script works with both cases, I checked
Hi all!
I tried to install it on a Xiaomi Mi A1. I got pretty far but I always get stuck here: ./klipper-install-debian.sh
No such a file or directory.
I described exactly what I did:
-root
-busybox
-linuxdeploy
BOOTSTRAP:
⦿ Distribution: Debian
⦿ Architecture: arm64
⦿ Distribution suite: stable
⦿ Install type: File
⦿ Install path: ${EXTERNAL_STORAGE}/debian.img
⦿ Image size (MB): 4000 ##empty any other option make filesystem error. now my img is 2.3GB
⦿ File system: ext4
⦿ User name: user
⦿ User password: 12345678
⦿ Localisation: en_US.UTF-8
INIT:
⦿ Enable: Enabled
⦿ System: sysv
⦿ Settings Async: Disabled
MOUNTS:
⦿ Enable: Enabled
⦿ Mount points: Source /storage/8092-1CED Target: /storage/8092-1CED ##8092-1CED root dir of phisical sdcard
SSH:
⦿ Enable: Enabled
GUI:
⦿ Enable: Enabled
⦿ Graphics subsystem: X11
⦿ Desktop enviroment Xterm
INSTALL
RESTART Phone
connect with bot connect
su root
e2fsck -f -y /${EXTERNAL_STORAGE}/debian.img ##result Pass 1-5
cat >> klipper-install-debian.sh ##paste install script
enter
exit
chmod +x klipper-install-debian.sh
./klipper-install-debian.sh ##no such a file or dir.
I have installed MainsailOS. Xsdl is on phone. I have both your script and systemd copied to linux install. I can connect to xsdl by following the instructions given on phone. Only a black screen come up with cursor on phone. I am trying to connect over wlan if that makes a diffence. Also using a Pi Zero W so wlan is only real option as I dont have usb micro to micro cable. These are warnings output when run. Thanks for any help or direction.
You can’t screen off because android will go to sleep. Klipperscreen coudn’t control smartphone screen.
You can add screensaver on debian, but it make screen black without shutting down screen backlight. As example xscreensaver. Just install xscreensaver and replace in /usr/local/bin/xterm:
“exec python3 ./screen.py” => “exec xscreensaver python3 ./screen.py”
Don’t forget to configure xscreensaver before using
Noob question but I got the shell script and the service file to work and can manually launch Klipperscreen on my phone but I can’t get the service file into the systemd directory to run on boot. It appears I don’t have write access to that directory. How do I migrate the service file to that directory or how do I gain write access to that directory?