自动启动 midori 浏览器无法在 Raspberry pi 上运行

Auto start up midori browser is not working on Raspberry pi

我正在尝试在 Raspberry Pi 中启动浏览器。这些是我到目前为止遵循的步骤:

  1. 我已经使用以下命令从根文件夹编辑了 .bashrc 文件:

sudo nano /home/pi/.bashrc

  1. 在文件末尾添加了以下行。

midori -e Fullscreen -a http://www.google.com

  1. 我重新启动了 Raspberry Pi。

sudo reboot

开机时不打开浏览器。如果我手动点击终端,它会打开浏览器。

我找到了解决方案。

在新版本中,此自动启动文件不支持它

sudo nano /etc/xdg/lxsession/LXDE/autostart

我将代码更改为以下自动启动文件。

sudo nano /etc/xdg/lxsession/LXDE-pi/autostart

你可以使用 crontab

sudo crontab -e

并添加

@reboot command_you_want_to_run &

我使用 LXDE-pi 的自动启动和一个 sh 文件解决了问题。

我必须安装 xautomation 来模拟用户输入

sudo apt-get install xautomation

在pi的家里我创建了一个sh文件

touch start_browser.sh

我在文件中插入了以下代码

#!/bin/sh

# running the browser on the main desktop
sudo -u pi epiphany-browser -a --profile ~/.config http://www.google.com/ --display=:0 & 
# waits a few seconds, we wait that the browser has started successfully   
sleep 15s;
# xautomation simulates the pressure on the F11 key for activate the browser in full screen mode on the main desktop
xte "key F11" -x:0

我用chmod命令给sh文件添加了可执行权限

sudo chmod 755 start_browser.sh

我已经修改了LXDE-pi会话的自动启动文件

sudo nano /etc/xdg/lxsession/LXDE-pi/autostart

通过将以下命令添加到 运行 我的 sh 文件

@/home/pi/start_browser.sh

现在我们的浏览器应该在每次启动时以全屏模式启动

如果没有,请检查 Raspberry 的配置是否启用了引导进入桌面环境

sudo raspi-config

Select:3 启用引导至 Desktop/Scratch

Select: 桌面 在图形桌面上以用户 'pi' 登录

享受

我得到了一个非常简单的解决方案。首先在你的 pi 上安装 midori。

sudo apt-get install midori

然后在此处添加您要自动启动的文件。

sudo nano /etc/xdg/lxsession/LXDE-pi/autostart

例如你想在重启后打开 google 浏览器。将此行添加到自动启动文件。

@midori -e Fullscreen -a http://google.com

保存文件并重启你的树莓派。现在,google 浏览器将在您每次重新启动时自动启动。

在最新版本的 raspberian 中你必须编辑

sudo vi .config/lxsession/LXDE-pi/autostart

为此

@midori -e Fullscreen -a http://google.com

上班..