Difference between revisions of "How to setup x11vnc server"

From FriendlyELEC WiKi
Jump to: navigation, search
(updated by API)
 
(updated by API)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
[[How to setup VNC server on NanoPC-T4/zh|查看中文]]
+
[[How to setup x11vnc server/zh|查看中文]]
  
==Step1: 安装VNC Server==
+
== Scope of this document ==
 +
* Ubuntu Focal Desktop system on RK3399/RK3568/RK3588 platforms
 +
* Debian Bullseye Desktop system on RK3588 platform
 +
* For FriendlyDesktop on RK3399 platform, refer to [[How to setup VNC server on NanoPC-T4|How to setup VNC server on NanoPC-T4]]
 +
 
 +
== Step 1: Install x11vnc ==
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
sudo apt-get install tightvncserver
+
sudo apt update
 +
sudo apt-get install x11vnc net-tools
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==Step2: 设置密码==
+
== Step 2: Set password ==
运行vnc server一次,会生成配置文件,并提示你为VNC Server设置一个密码:
+
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
tightvncserver :1
+
su pi
 +
x11vnc -storepasswd
 
</syntaxhighlight>
 
</syntaxhighlight>
设置密码后,为了方便接下来的操作,先退出Vnc server:
+
 
 +
== Step 3: Create .Xauthority ==
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
tightvncserver -kill :1
+
touch /home/pi/.Xauthority
 +
xauth add :0 . `mcookie`
 
</syntaxhighlight>
 
</syntaxhighlight>
  
==Step3: 配置VNC server==
+
== Step 4: Configure automatic desktop login ==
编辑~/.vnc/xstartup文件,在尾部添加:
+
=== For Ubuntu Focal Desktop ===
 +
Create directory and file
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
lxterminal &
+
sudo mkdir /etc/sddm.conf.d
/usr/bin/lxsession -s LXDE &
+
sudo vim /etc/sddm.conf.d/autologin
 
</syntaxhighlight>
 
</syntaxhighlight>
手动启动VNC Server,测试一下是否可以工作:
+
Content of autologin file:
<syntaxhighlight lang="bash">
+
<syntaxhighlight lang="ini">
vncserver -geometry 1280x800
+
[Autologin]
 +
User=pi
 +
Session=lxqt.desktop
 +
Relogin=false
 
</syntaxhighlight>
 
</syntaxhighlight>
在电脑上打开VNC客户端,输入开发板IP地址与5901的端口号,比如开发板的IP是192.168.1.131,则输入 192.168.1.131:5901,如下图所示: <br />
+
Restart.
[[File:vncserver-inputaddress.png|frameless|600px]] <br />
+
 
连接成功的话,进入下一步。
+
=== For Debian Bullseye Desktop ===
==Step4: 设置开机自动启动VNC server==
+
By default, automatic login is enabled. Check configuration with the following file:
新建一个文件 /etc/systemd/system/vncserver@.service,内容如下:
+
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 +
$ grep autologin-user /etc/lightdm/lightdm.conf
 +
# autologin-user = User to log in with by default (overrides autologin-guest)
 +
# autologin-user-timeout = Number of seconds to wait before loading default user
 +
autologin-user=pi
 +
autologin-user-timeout=0
 +
</syntaxhighlight>
 +
 +
== Step 5: Run x11vnc at startup ==
 +
Create file /etc/systemd/system/x11vnc.service
 +
<syntaxhighlight lang="ini">
 +
sudo vim /etc/systemd/system/x11vnc.service
 +
</syntaxhighlight>
 +
Content of x11vnc.service:
 +
<syntaxhighlight lang="ini">
 
[Unit]
 
[Unit]
Description=Start TightVNC server at startup
+
Description=Start x11vnc at startup.
After=syslog.target network.target
+
After=network-online.target
  
 
[Service]
 
[Service]
Type=forking
+
Type=simple
 +
ExecStart=/usr/bin/x11vnc -display :0 -auth /home/pi/.Xauthority -rfbauth /home/pi/.vnc/passwd -rfbport 5900 -forever -loop -noxdamage -repeat -shared -capslock -nomodtweak
 
User=pi
 
User=pi
PAMName=pi
+
Group=pi
PIDFile=/home/pi/.vnc/%H:%i.pid
+
WorkingDirectory=/home/pi
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
+
ExecStop=/bin/kill -TERM $MAINPID
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :%i
+
ExecReload=/bin/kill -HUP $MAINPID
ExecStop=/usr/bin/vncserver -kill :%i
+
KillMode=control-group
 +
Restart=on-failure
 +
Environment=DISPLAY=:0
 +
Environment=XAUTHORITY=/home/pi/.Xauthority
  
 
[Install]
 
[Install]
WantedBy=multi-user.target
+
WantedBy=graphical.target
 
</syntaxhighlight>
 
</syntaxhighlight>
创建符号链接以实现开机自启动: <br />
+
Enable systemd service
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
sudo ln -s /etc/systemd/system/vncserver@.service /etc/systemd/system/multi-user.target.wants/vncserver@1.service
+
sudo systemctl daemon-reload
 +
sudo systemctl restart x11vnc.service
 
</syntaxhighlight>
 
</syntaxhighlight>
重启开发板:
+
 
<syntaxhighlight lang="bash">
+
== Step 6: Access from a computer ==
sudo reboot
+
Use VNC client to access the following address:<br />
</syntaxhighlight>
+
Board IP:5900
==Step5: 连接到VNC server==
+
 
在电脑上打开VNC Viewer,输入开发板IP地址与5901的端口号登录开发板,显示桌面如下图所示: <br />
+
== Known Issues ==
[[File:vncserver-friendlydesktop.png|frameless|600px]]
+
Poor performance, for testing purposes only

Latest revision as of 09:24, 21 June 2024

查看中文

1 Scope of this document

  • Ubuntu Focal Desktop system on RK3399/RK3568/RK3588 platforms
  • Debian Bullseye Desktop system on RK3588 platform
  • For FriendlyDesktop on RK3399 platform, refer to How to setup VNC server on NanoPC-T4

2 Step 1: Install x11vnc

sudo apt update
sudo apt-get install x11vnc net-tools

3 Step 2: Set password

su pi
x11vnc -storepasswd

4 Step 3: Create .Xauthority

touch /home/pi/.Xauthority
xauth add :0 . `mcookie`

5 Step 4: Configure automatic desktop login

5.1 For Ubuntu Focal Desktop

Create directory and file

sudo mkdir /etc/sddm.conf.d
sudo vim /etc/sddm.conf.d/autologin

Content of autologin file:

[Autologin]
User=pi
Session=lxqt.desktop
Relogin=false

Restart.

5.2 For Debian Bullseye Desktop

By default, automatic login is enabled. Check configuration with the following file:

$ grep autologin-user /etc/lightdm/lightdm.conf
# autologin-user = User to log in with by default (overrides autologin-guest)
# autologin-user-timeout = Number of seconds to wait before loading default user
autologin-user=pi
autologin-user-timeout=0

6 Step 5: Run x11vnc at startup

Create file /etc/systemd/system/x11vnc.service

sudo vim /etc/systemd/system/x11vnc.service

Content of x11vnc.service:

[Unit]
Description=Start x11vnc at startup.
After=network-online.target
 
[Service]
Type=simple
ExecStart=/usr/bin/x11vnc -display :0 -auth /home/pi/.Xauthority -rfbauth /home/pi/.vnc/passwd -rfbport 5900 -forever -loop -noxdamage -repeat -shared -capslock -nomodtweak
User=pi
Group=pi
WorkingDirectory=/home/pi
ExecStop=/bin/kill -TERM $MAINPID
ExecReload=/bin/kill -HUP $MAINPID
KillMode=control-group
Restart=on-failure
Environment=DISPLAY=:0
Environment=XAUTHORITY=/home/pi/.Xauthority
 
[Install]
WantedBy=graphical.target

Enable systemd service

sudo systemctl daemon-reload
sudo systemctl restart x11vnc.service

7 Step 6: Access from a computer

Use VNC client to access the following address:
Board IP:5900

8 Known Issues

Poor performance, for testing purposes only