VNC
This guide explains how to setup a VNC server on your phone.
x11vnc
Using x11vnc, which is in the Alpine repos. You need a running X server (e.g. running Xfce), then you just run x11vnc on the device in a terminal/tty and connect to it. From there, you can manipulate the previously running X server. You might need to specify the X server if x11vnc does not detect it (e.g. by passing -display :0
to it or doing a export DISPLAY=:0
before running it, assuming the display is at :0
)
If you want to launch x11vnc from ssh while you have already logged in from the display managers of your choice, you need to find the Xauthority file for the logged in user and use that in the command of x11vnc, for example, if your user id is 10000 and you're using gdm:
x11vnc -auth /run/user/10000/gdm/Xauthority -display :0
Location of Xauthority file may differ with different display manager.
wayvnc
This works for wlroots-based Wayland compositors like Phosh or Sway[1]. By default wayvnc listens to 127.0.0.1:5900
Install wayvnc, and start a server listening to any network interface on the phone:
$ sudo apk add wayvnc
(1/3) Installing aml (0.2.1-r0)
(2/3) Installing neatvnc (0.4.0-r0)
(3/3) Installing wayvnc (0.4.1-r0)
Executing busybox-1.35.0-r13.trigger
OK: 971 MiB in 563 packages
$ wayvnc 0.0.0.0
Or listen to 172.16.42.1
on port 9999
:
$ wayvnc 172.16.42.1 9999
After a server setup, use a client, for example, tigervnc-client to connect to the server 172.16.42.1:9999
, and press Connect:
Have fun with it.
Troubleshooting
XDG_RUNTIME_DIR not set in the environment
This happens when XDG_RUNTIME_DIR
is not set, usually in SSH sessions.
$ wayvnc 0.0.0.0
error: XDG_RUNTIME_DIR not set in the environment.
ERROR: Failed to initialise wayland
Just set it with:
$ export XDG_RUNTIME_DIR=/run/user/10000
And start the server again.
Connection refused/timed out
Check if your VNC server is started, and the port is open to the clients. By default, incoming packets from USB Networking are accepted by nftables on the phone [2].
But when connecting via Wi-Fi, you need to open the port.
If using port 5900
, it's as simple as installing postmarketos-config-nftables-vncserverPMOS and restarting nftables:
# apk add postmarketos-config-nftables-vncserver
(1/1) Installing postmarketos-config-nftables-vncserver (0.10-r0)
Executing postmarketos-base-20-r0.trigger
Configuring a getty on port ttyMSM0 with baud rate 115200
OK: 1006 MiB in 570 packages
# service nftables restart
* Stopping firewall ... [ ok ]
* Loading nftables state and starting firewall ...
However, when connecting to a custom port like 9999
, it requires to add a rule to accept the connection:
# nft add rule inet filter input iifname wlan0 tcp dport 9999 accept comment "Accept custom port over wifi"
No route to host
Check if the host even exists on the LAN.
Related pages
See also
- Side Displays, Using a Linux phone as a secondary monitor by User:R
- VNC Server for Pinephone
- Is remote desktop making a comeback in GNOME on Wayland?