我正在使用 Ubuntu 18.04 LTS 和 Windows 10 PC,Synergy 版本为:1.11.1rc2-4a90760e。在 Windows 客户端上,它会在登录前自动启动,并且运行良好。我的 ubuntu 服务器没有自动启动功能,我想添加它,以便在 Ubuntu 登录之前就能登录 Windows。
我尝试了多种解决方案,但都无济于事。最后,我决定创建一个调用应用程序启动脚本的服务文件。检查服务状态:
Loaded: loaded (/etc/systemd/system/[email protected]; enabled; vendor preset: enabled)
Active: active (running) since Thu 2021-02-11 08:09:05 EAT; 36min ago
Main PID: 1021 (synergysauto)
Tasks: 4 (limit: 4915)
CGroup: /system.slice/system-synergy.slice/[email protected]
├─1021 /bin/bash /usr/local/bin/synergysauto
└─1064 synergys -f -d INFO --name Hp -c /etc/synergy.conf -a 10.42.0.1:45000 --log /var/log/synergy.log
Feb 11 08:41:47 Delta synergysauto[1021]: [2021-02-11T08:41:47] INFO: switch from "Lenovo" to "Hp" at 1361,196
Feb 11 08:41:47 Delta synergysauto[1021]: [2021-02-11T08:41:47] INFO: entering screen
Feb 11 08:41:48 Delta synergysauto[1021]: [2021-02-11T08:41:48] INFO: switch from "Hp" to "Lenovo" at 0,289
Feb 11 08:41:48 Delta synergysauto[1021]: [2021-02-11T08:41:48] INFO: leaving screen
Feb 11 08:42:08 Delta synergysauto[1021]: [2021-02-11T08:42:08] INFO: switch from "Lenovo" to "Hp" at 1355,401
Feb 11 08:42:08 Delta synergysauto[1021]: [2021-02-11T08:42:08] INFO: entering screen
Feb 11 08:42:09 Delta synergysauto[1021]: [2021-02-11T08:42:09] INFO: switch from "Hp" to "Lenovo" at 0,251
Feb 11 08:42:09 Delta synergysauto[1021]: [2021-02-11T08:42:09] INFO: leaving screen
Feb 11 08:44:57 Delta synergysauto[1021]: [2021-02-11T08:44:57] INFO: switch from "Lenovo" to "Hp" at 1364,586
Feb 11 08:44:57 Delta synergysauto[1021]: [2021-02-11T08:44:57] INFO: entering screen
~
检查服务文件:
[Unit]
Description=Synergy Server
After=network.target
[Service]
ExecStart=/usr/local/bin/synergysauto
Restart=on-failure
User=%i
[Install]
WantedBy=multi-user.target
synergys 启动文件作为一个进程启动,如服务状态输出所示,如下所示:
#!/bin/bash
# use the following defined address and configuration file.
# The option --daemon runs the process in the background
# Use Hp as the server name instead of the hostname
# Execute
synergys -f -d INFO --name Hp -c /etc/synergy.conf -a 10.42.0.1:45000 --log /var/log/synergy.log
# Exit status
exit 0
现在一切正常,只是服务器在注销后无法访问主屏幕。我已在登录 GUI 之前访问的虚拟控制台中确认了这一点。在 synergy 日志文件中有“警告”消息,指出无法离开屏幕,Hp to Lenovo
这是我在配置文件中设置的屏幕。如果仔细检查,您会发现我必须以 GUI 中的某个用户身份登录,synergy 才能访问主屏幕X Server
。服务使用命令启动sudo systemctl start synergy@$(whoami)
并使用启用sudo systemctl enable synergy@$(whoami)
。
我怎样才能让显示管理器启动服务器?提前致谢。