shell - 在 systemd 服务上运行 gui 应用程序时出错
问题描述
我正在尝试在 systemd 服务中运行一个 gui 命令,我希望它在系统启动时执行。
这些是我的文件。
oversteer.sh 文件:
#!/bin/bash
sleep 1s
export DISPLAY=:99.0
export SCREEN_WIDTH=1200
export SCREEN_HEIGHT=960
export SCREEN_DEPTH=24
export GEOMETRY="${SCREEN_WIDTH}x${SCREEN_HEIGHT}x${SCREEN_DEPTH}"
sudo oversteer --autocenter 45 &
sudo oversteer --range 720
oversteer.service 文件:
[Unit]
Description = oversteer
After=local-fs.target
[Service]
Environment="DISPLAY=:0"
Environment="XAUTHORITY=/home/ubuntu/.Xauthority"
ExecStart=/home/ubuntu/g29_steering_wheel/autostart_scripts/oversteer.sh
Restart=on-failure
Type=simple
StandardOutput=journal+console
[Install]
WantedBy=multi-user.target
我已将此文件放在 /etc/systemd/system 中,并已授予可执行权限和 root 权限。但是,该服务似乎因为没有显示而失败。
错误如下:
Unable to init server: Could not connect: Connection refused
Unable to init server: Could not connect: Connection refused
Unable to init server: Could not connect: Connection refused
Unable to init server: Could not connect: Connection refused
(oversteer:8052): Gdk-CRITICAL **: 08:00:50.744: gdk_cursor_new_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
(oversteer:8053): Gdk-CRITICAL **: 08:00:50.763: gdk_cursor_new_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_gtk3.py", line 45, in <module>
cursors.MOVE : Gdk.Cursor.new(Gdk.CursorType.FLEUR),
TypeError: constructor returned NULL
我正在使用 ubuntu 20.04 在 raspi 4 上运行。转向过度是一个用于控制我的操纵杆参数的包。
解决方案
推荐阅读
- javascript - 下拉自动填充字段后是否可以手动编辑数据?
- javascript -
与 vue 中的 {{ foo }}?
- c# - 如何使用 webSocketOptions.AllowedOrigins?
- asp.net-core - 在 dot net core razor pages - 你如何默认创建页面上的下拉选项?
- python - Python:如何在一系列立方线中测试相对直线?
- shopify - 为什么我在通过 Shopify CLI 创建 Shopify 应用程序后收到“根路径”错误?
- python - 在读取熊猫中的csv时,当它们也是分隔符时,如何保留文本中的逗号?
- c - 为什么 recvfrom() 返回错误的发件人地址?
- reactjs - 测试没有逻辑的组件
- colors - 将 sRGB D65 转换为 CIELab D50