You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

树莓派3开机自启动Shell应用(Universal G-Code Sender)问题求助

解决树莓派3开机自动启动Universal G-Code Sender的方法

第一步:确保脚本具备可执行权限

先确认你的ugsplatform脚本有执行权限,打开终端运行:

chmod +x /home/fifex/Desktop/ugsplatform-pi/bin/ugsplatform

方法一:桌面自启动配置(推荐,适用于图形界面程序)

树莓派默认LXDE桌面可通过autostart文件添加开机启动项:

  • 打开终端,编辑autostart文件:
    nano ~/.config/lxsession/LXDE-pi/autostart
    
  • 在文件末尾添加一行(添加延迟避免系统未加载完桌面就启动程序):
    @sleep 10 && /home/fifex/Desktop/ugsplatform-pi/bin/ugsplatform
    
  • 按Ctrl+O保存,Ctrl+X退出,重启树莓派测试。

方法二:systemd服务(适合后台运行或精确控制场景)

如果桌面自启动无效,可创建systemd服务:

  • 创建服务文件:
    sudo nano /etc/systemd/system/ugsplatform.service
    
  • 粘贴以下内容(注意替换用户名为fifex,延迟时间可按需调整):
    [Unit]
    Description=Universal G-Code Sender Auto Start
    After=graphical.target
    
    [Service]
    User=fifex
    Environment=DISPLAY=:0
    Environment=XAUTHORITY=/home/fifex/.Xauthority
    ExecStart=/bin/bash -c "sleep 15 && /home/fifex/Desktop/ugsplatform-pi/bin/ugsplatform"
    Restart=on-failure
    
    [Install]
    WantedBy=graphical.target
    
  • 保存退出后,启用并启动服务:
    sudo systemctl daemon-reload
    sudo systemctl enable ugsplatform.service
    
  • 重启树莓派验证效果。

故障排查

  • 若启动失败,查看systemd日志定位错误:
    sudo journalctl -u ugsplatform.service -f
    
  • 核对脚本路径是否拼写正确;
  • 延迟时间可根据系统启动速度调整(10-20秒区间均可)。

内容的提问来源于stack exchange,提问作者SpoonyGato

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.16 06:15:11