在启动时启动 x11vnc

zee*_*ena 5 arch-linux x11 systemd x11vnc

我在我的远程 PC 上使用 archlinux 版本 3.10.27-1-ARCH,我希望它在成功启动时启动 x11vnc 服务器。虽然我可以手动启动 x11vnc 服务器,但我无法自动启动它。的配置/etc/systemd/system/x11vnc.service如下


[Unit]
Description=VNC Server for X11
Requires=graphical.target
After=graphical.target

[Service]
ExecStart=/usr/bin/x11vnc -display :0 -nopw
Run Code Online (Sandbox Code Playgroud)


使用命令查看服务状态:systemctl status x11vnc

x11vnc.service - VNC Server for X11
   Loaded: loaded (/etc/systemd/system/x11vnc.service; enabled)
   Active: inactive (dead)
Run Code Online (Sandbox Code Playgroud)


以及命令的 dBus 输出: dmesg|grep x11vnc

[    5.467201] systemd[1]: Found dependency on x11vnc.service/start
[    5.467285] systemd[1]: Breaking ordering cycle by deleting job x11vnc.service/start
[    5.467335] systemd[1]: Job x11vnc.service/start deleted to break ordering cycle starting with graphical.target/start
Run Code Online (Sandbox Code Playgroud)

我确实从dmesg输出中感觉到存在循环依赖,但我无法理解是什么。

slm*_*slm 2

我发现这个线程显示了类似的设置x11vnc为 Systemd 服务的任务。该线程的标题为:Index\xc2\xbb Newbie Corner\xc2\xbb 如何使用 systemd 在启动时启用 x11vnc ?

\n\n

来自该线程中的评论

\n\n
    \n
  1. 创建文件:/etc/systemd/system/x11vnc.service

    \n\n
    [Unit]\nDescription=VNC Server for X11\nRequires=display-manager.service\nAfter=display-manager.service\n\n[Service]\nType=forking\nExecStart=/usr/bin/x11vnc -norc -forever -shared -bg -rfbauth /etc/x11vnc.pass -allow 192.168.1. -autoport 5900 -o /var/log/x11vnc.log\n
    Run Code Online (Sandbox Code Playgroud)
  2. \n
  3. 创建文件:/etc/systemd/system/graphical.target

    \n\n
    #  This file is part of systemd.\n#\n#  systemd is free software; you can redistribute it and/or modify it\n#  under the terms of the GNU Lesser General Public License as published by\n#  the Free Software Foundation; either version 2.1 of the License, or\n#  (at your option) any later version.\n\n[Unit]\nDescription=Graphical Interface\nDocumentation=man:systemd.special(7)\nRequires=multi-user.target\nAfter=multi-user.target\nConflicts=rescue.target\nWants=display-manager.service\nWants=x11vnc.service\nAllowIsolate=yes\n\n[Install]\nAlias=default.target\n
    Run Code Online (Sandbox Code Playgroud)
  4. \n
  5. 启用S​​ystemd服务

    \n\n
    $ sudo systemctl enable graphical.target\n
    Run Code Online (Sandbox Code Playgroud)\n\n

    这应该创建一个像这样的链接:

    \n\n
    \n

    /etc/systemd/system/default.target -> /etc/systemd/system/graphical.target

    \n
  6. \n
  7. 重启

  8. \n
\n