我一直试图让TigerVNC在桌面Ubuntu18.04 (GNOME等)的干净安装上工作。运行vncserver :1 -localhost no
使我能够很好地连接,但我的systemd服务似乎无法工作。
系统启动后的日志:
Xvnc TigerVNC 1.7.0 - built Dec 5 2017 09:25:01
Copyright (C) 1999-2016 TigerVNC Team and many others (see README.txt)
See http://www.tigervnc.org for information on TigerVNC.
Underlying X server release 11905000, The X.Org Foundation
Wed Jul 10 15:13:27 2019
vncext: VNC extension running!
vncext: Listening for VNC connections on all interface(s), port 5901
vncext: created VNC server for screen 0
vncconfig: unable to open display ":1"
** (process:1184): WARNING **: 15:13:28.311: Could not make bus activated clients aware of XDG_CURRENT_DESKTOP=GNOME environment variable: Could not connect: Connection refused
在终端(vncserver :1 -localhost no
)中手动启动vncserver后登录:
Xvnc TigerVNC 1.7.0 - built Dec 5 2017 09:25:01
Copyright (C) 1999-2016 TigerVNC Team and many others (see README.txt)
See http://www.tigervnc.org for information on TigerVNC.
Underlying X server release 11905000, The X.Org Foundation
Wed Jul 10 15:14:25 2019
vncext: VNC extension running!
vncext: Listening for VNC connections on all interface(s), port 5901
vncext: created VNC server for screen 0
XIO: fatal IO error 11 (Resource temporarily unavailable) on X server ":1"
after 175 requests (174 known processed) with 0 events remaining.
xstartup:
#!/bin/sh
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
vncconfig -iconic & dbus-launch --exit-with-session gnome-session &
vncserver@.service
[Unit]
Description=TigerVNC Service
After=syslog.target network.target
[Service]
Type=simple
User=
PAMName=login
PIDFile=/home//.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver :%i -localhost no
ExecStop=/usr/bin/vncserver -kill :%i
[Install]
WantedBy=multi-user.target
发布于 2019-07-17 08:31:19
经过一些尝试和错误之后,我决定在用户登录后,以用户模式运行该进程。服务在用户登录后启动,并且启用了自动登录功能,对我来说非常好。
我删除了/etc/systemd/system/vncserver@.service
文件,并在$HOME/.local/share/systemd/user/vncserver@.service
中创建了一个包含以下内容的新文件(并创建了丢失的文件夹)。
vncserver@.service
[Unit]
Description=TigerVNC Service
[Service]
Type=forking
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver :%i -localhost no
ExecStop=/usr/bin/vncserver -kill :%i
[Install]
WantedBy=default.target
然后,我用systemctl daemon-reload --user
启用了服务,用systemctl enable vncserver@1 --user
启用了它。
发布于 2020-10-08 03:28:15
Paul发现的用su解决问题是迄今为止在Ubuntu18.04上将TigerVNC作为一项服务启动的最佳解决方案。
要获得Ubuntu桌面(而不是Gnome桌面),请编辑~/..vnc/xstartup:
#!/bin/sh
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
vncconfig −nowin &
dbus-launch --exit-with-session env GNOME_SHELL_SESSION_MODE=ubuntu gnome-session --session=ubuntu &
https://unix.stackexchange.com/questions/529375
复制相似问题