配置树莓派通电开机或重启后进入桌面环境时自动打开浏览器访问指定网址。
手动执行命令验证效果
root@raspberrypi:~# chromium-browser https://bi.example.com配置开机自启动
编写脚本
将上面测试好的命令写入到 shell 脚本中,放到有权限执行的目录下。由于我这里树莓派开机后默认使用 admin 用户身份打开桌面环境,所以我把启动脚本放到 admin 用户家目录下。
root@raspberrypi:~# cat /home/admin/open_browser.sh
#!/bin/bash
sleep 30
chromium-browser https://bi.example.com
root@raspberrypi:~#添加执行权限
root@raspberrypi:~# chown admin:admin /home/admin/open_browser.sh
root@raspberrypi:~# chmod u+x /home/admin/open_browser.sh
root@raspberrypi:~#将脚本加入自启动
新增如下所示最后一行配置,执行上面创建好的脚本即可。
root@raspberrypi:~# vi /etc/xdg/lxsession/LXDE-pi/autostart
@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@xscreensaver -no-splash
@sh /home/admin/open_browser.sh
root@raspberrypi:~#
本文采用 知识共享署名4.0 国际许可协议进行许可。
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名。
如果您的问题未解决,欢迎微信扫描右侧二维码与我联系。