VNC: Difference between revisions
m →See also: Side Displays |
m Replace deprecated <source> tags with <syntaxhighlight> |
||
Line 8: | Line 8: | ||
Install {{aport|wayvnc}}, and start a server listening to any network interface on the phone: | Install {{aport|wayvnc}}, and start a server listening to any network interface on the phone: | ||
< | <syntaxhighlight lang=shell-session> | ||
$ sudo apk add wayvnc | $ sudo apk add wayvnc | ||
(1/3) Installing aml (0.2.1-r0) | (1/3) Installing aml (0.2.1-r0) | ||
Line 16: | Line 16: | ||
OK: 971 MiB in 563 packages | OK: 971 MiB in 563 packages | ||
$ wayvnc 0.0.0.0 | $ wayvnc 0.0.0.0 | ||
</ | </syntaxhighlight> | ||
Or listen to <code>172.16.42.1</code> on port <code>9999</code>: | Or listen to <code>172.16.42.1</code> on port <code>9999</code>: | ||
< | <syntaxhighlight lang=shell-session> | ||
$ wayvnc 172.16.42.1 9999 | $ wayvnc 172.16.42.1 9999 | ||
</ | </syntaxhighlight> | ||
Line 36: | Line 36: | ||
=== XDG_RUNTIME_DIR not set in the environment === | === XDG_RUNTIME_DIR not set in the environment === | ||
This happens when <code>XDG_RUNTIME_DIR</code> is not set, usually in SSH sessions. | This happens when <code>XDG_RUNTIME_DIR</code> is not set, usually in SSH sessions. | ||
< | <syntaxhighlight lang=shell-session> | ||
$ wayvnc 0.0.0.0 | $ wayvnc 0.0.0.0 | ||
error: XDG_RUNTIME_DIR not set in the environment. | error: XDG_RUNTIME_DIR not set in the environment. | ||
ERROR: Failed to initialise wayland | ERROR: Failed to initialise wayland | ||
</ | </syntaxhighlight> | ||
Just set it with: | Just set it with: | ||
< | <syntaxhighlight lang=shell-session> | ||
$ export XDG_RUNTIME_DIR=/run/user/10000 | $ export XDG_RUNTIME_DIR=/run/user/10000 | ||
</ | </syntaxhighlight> | ||
And start the server again. | And start the server again. | ||
Line 55: | Line 55: | ||
But when connecting via Wi-Fi, you need to open the port. | But when connecting via Wi-Fi, you need to open the port. | ||
If using port <code>5900</code>, it's as simple as installing {{pmaport|postmarketos-config-nftables-vncserver}} and restarting nftables: | If using port <code>5900</code>, it's as simple as installing {{pmaport|postmarketos-config-nftables-vncserver}} and restarting nftables: | ||
< | <syntaxhighlight lang=shell-session> | ||
# apk add postmarketos-config-nftables-vncserver | # apk add postmarketos-config-nftables-vncserver | ||
(1/1) Installing postmarketos-config-nftables-vncserver (0.10-r0) | (1/1) Installing postmarketos-config-nftables-vncserver (0.10-r0) | ||
Line 64: | Line 64: | ||
* Stopping firewall ... [ ok ] | * Stopping firewall ... [ ok ] | ||
* Loading nftables state and starting firewall ... | * Loading nftables state and starting firewall ... | ||
</ | </syntaxhighlight> | ||
However, when connecting to a custom port like <code>9999</code>, it requires to add a rule to accept the connection: | However, when connecting to a custom port like <code>9999</code>, it requires to add a rule to accept the connection: | ||
< | <syntaxhighlight lang=shell-session> | ||
# nft add rule inet filter input iifname wlan0 tcp dport 9999 accept comment "Accept custom port over wifi" | # nft add rule inet filter input iifname wlan0 tcp dport 9999 accept comment "Accept custom port over wifi" | ||
</ | </syntaxhighlight> | ||
=== No route to host === | === No route to host === |
Revision as of 06:27, 14 April 2024
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
)
wayvnc
This works for wayland sessions like Phosh[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 :
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?