一、准备工作
系统要求:
- 使用 Raspberry Pi OS with Desktop(推荐最新版 Bookworm)。
- 硬件建议:树莓派 3B+ / 4 / 5(性能更好,避免卡顿)。
- 连接外设:显示器、键盘、鼠标(首次配置需要)。
二、安装与配置 Chromium Kiosk 模式
1. 更新系统并安装 Chromium
sudo apt update && sudo apt upgrade -y
sudo apt install chromium-browser -y注:新版 Raspberry Pi OS 已预装 Chromium,若已存在可跳过。
2. 创建自动启动脚本
编辑 ~/.config/autostart/chromium-kiosk.desktop 文件(若目录不存在则创建):
mkdir -p ~/.config/autostart
nano ~/.config/autostart/chromium-kiosk.desktop填入以下内容(替换 YOUR_URL 为你的目标网页):
[Desktop Entry]
Type=Application
Exec=/usr/bin/chromium-browser --kiosk --disable-dev-shm-usage --disk-cache-size=104857600 --no-first-run --enable-logging --v=1 YOUR_URL
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name=Chromium Kiosk
Comment=Start Chromium in Kiosk Mode参数说明:
--kiosk:全屏无地址栏模式。--disable-dev-shm-usage:解决共享内存限制(避免崩溃)。--disk-cache-size=104857600:设置磁盘缓存为 100MB。--no-first-run:跳过首次运行向导。
3. 禁用屏幕保护与休眠
防止屏幕自动关闭或进入休眠:
# 禁用屏幕保护
xset s off
xset -dpms
xset s noblank
# 永久生效:编辑 ~/.xprofile
echo "xset s off" >> ~/.xprofile
echo "xset -dpms" >> ~/.xprofile
echo "xset s noblank" >> ~/.xprofile4. 隐藏鼠标指针(可选)
安装 unclutter 隐藏空闲鼠标:
sudo apt install unclutter -y
echo "unclutter -idle 1" >> ~/.xprofile三、开机自动启动优化(针对 Bookworm 系统)
若上述方法无效(Bookworm 使用 Wayland 而非 X11),需改用 systemd 服务:
创建服务文件:
sudo nano /etc/systemd/system/kiosk.service填入内容(替换
YOUR_URL和用户pi):[Unit] Description=Chromium Kiosk Wants=graphical.target After=graphical.target [Service] User=pi Environment=DISPLAY=:0 Environment=XAUTHORITY=/home/pi/.Xauthority ExecStart=/usr/bin/chromium-browser --kiosk --disable-dev-shm-usage YOUR_URL Restart=on-failure [Install] WantedBy=graphical.target启用服务:
sudo systemctl enable kiosk.service sudo systemctl start kiosk.service
四、中文输入支持(如需交互)
若 Kiosk 需用户输入中文:
安装拼音输入法:
sudo apt install fcitx fcitx-pinyin -y im-config -n fcitx- 重启后按
Ctrl+Space切换输入法。
五、安全与维护建议
- 禁用快捷键:通过
--disable-component-update --disable-translate等参数限制用户操作。 - 看门狗重启:添加 systemd 监控脚本,检测到浏览器崩溃时自动重启。
- 远程管理:开启 SSH,便于后续更新 URL 或调试。
验证步骤
- 重启树莓派:
sudo reboot。 - 观察是否自动全屏打开指定网页。
- 测试触摸/键盘交互(如需)。
提示:若使用非官方镜像(如 Chilipie-Kiosk),可直接烧录预制系统,简化配置流程。


Comments | NOTHING