[How To] KlipperScreen on Android Smart Phones


you can use any kind of smartphone/android device running xsdl.

I run it an old HTC Desire S (Android 4.2.2) and Samsung A3 2015 (lineageos 15).

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-

# 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 ]
    echo "Screen is OFF and Locked. Turning screen on..."
    adb shell input keyevent 26

adb shell dumpsys nfc | grep 'mScreenState=' | grep ON_LOCKED> /dev/null 2>&1
if [ $? -lt 1 ]
    echo "Screen is Locked. Unlocking..."
    adb shell input keyevent 82

# start xsdl
adb shell am start-activity x.org.server/.MainActivity

echo -n "Waiting for x-server to be ready "
while [ $ret -gt 0 ] && [ $timeout -lt 60 ]
    xset -display :100 -q > /dev/null 2>&1
    timeout=$( expr $timeout + 1 )
    echo -n "." 
    sleep 1
echo ""
if [ $timeout -lt 60 ]
    DISPLAY=:100 /home/pi/.KlipperScreen-env/bin/python screen.py
    exit 0
    exit 1

and here is the changed systemd service:




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”…

Hello! I tried install klipperscreen, but my xsdl only shows the linux desktop… How did you get klipperscreen?

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 :smiley:

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 :slight_smile:

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.


  • Second install XSDL server app from google play

  • Third you must create klipper-install-debian.sh by command:

cat >> klipper-install-debian.sh

and paste this script:

chmod +x klipper-install-debian.sh

This script install klipper, moonracker and KlipperScreen.

Printer must be connected to device when the installation is in progress!!!

  • Create and configure ~/klipper_config/KlipperScren.conf
  • In Linuxdepoy click Stop then Start

When Klipper and Klipperscreen startting XSDL must be stared and printer must be connected to the phone!

Enjoy! :wink:

P.S.: You can connect to the fluidd web interface in browser at http://app.fluidd.xyz/ and http://dev-app.fluidd.xyz/
API URL is: http://your.printer.ip.adress:7125

1 Like

Worth an own topic → Moved

Hello, great tutorial. One question:
you write

must be “stable” and you need to enable X11 GUI with XTerm in properties.

but in your script it is

if ! grep xterm “$HOME/.xsession” > /dev/null
echo “Configure container with XTerm graphics over vnc!”
exit 1

Should the container be with X11 GUI and Xterm or VNC and XTerm?
Can you please clearify that?

Thanks in advance

1 Like

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

1 Like

Thanks for the fast anwser. I will use X11 and Xterm.

Got this set up today on my old Nexus 6P, great so far…but has anyone figured out a way to make the screen timeout work properly?

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:

⦿ 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
⦿ Enable: Enabled
⦿ System: sysv
⦿ Settings Async: Disabled
⦿ Enable: Enabled
⦿ Mount points: Source /storage/8092-1CED Target: /storage/8092-1CED ##8092-1CED root dir of phisical sdcard
⦿ Enable: Enabled
⦿ Enable: Enabled
⦿ Graphics subsystem: X11
⦿ Desktop enviroment Xterm



connect with bot connect
su root
e2fsck -f -y /${EXTERNAL_STORAGE}/debian.img
##result Pass 1-5

start deploy(play button)

/data/data/ru.meefik.linuxdeploy/files/bin/linuxdeploy shell

usermod -a -G aid_everybody user
chsh -s /bin/bash user

/data/data/ru.meefik.linuxdeploy/files/bin/linuxdeploy stop -u
start deploy(play button)
/data/data/ru.meefik.linuxdeploy/files/bin/linuxdeploy shell

apt update ##0 update
apt upgrade ##0 upgrade

cat >> klipper-install-debian.sh
##paste install script
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.
Screenshot 2021-11-14 232553

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

This is not nessecary:

⦿ Enable: Enabled
⦿ Mount points: Source /storage/8092-1CED Target: /storage/8092-1CED ##8092-1CED root dir of phisical sdcard

This guide is a little outdated, after installing debian restart phone, start debian, connect by putty and make this commands:

sudo apt install curl -y
curl -sL https://gist.githubusercontent.com/CODeRUS/a5ec4a456f5b58186cbebb66a8542a2e/raw/klipper-install-debian.sh | bash -
1 Like

The buttons work quite well with my Xiaomi Mi8 but scrolling with bars doesn’t work. Is anyone else having this issue?

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?

Have you tried to use sudo to get permission to write to the folder?
Hope this helps

I figured out you have to edit the file in SSH you can’t edit with root in WinSCP.