LoginSignup
9
9

More than 1 year has passed since last update.

Raspberry Pi 起動時に Chromium をフルスクリーンで表示してキオスク端末っぽく使用する

Last updated at Posted at 2022-01-03

ラズパイで作りたいものがあって、その前提として、ラズパイをキオスク端末っぽくセットアップしたかったのでそのためのメモ。

前提条件

機種: Raspberry Pi 4B (メモリ4GB)
OS: Linux raspberrypi 5.10.63-v7l+

デスクトップ環境

デフォルトのデスクトップ環境でメモリを調べたら以下のような感じ。

$ free -m
               total        used        free      shared  buff/cache   available
Mem:            3839         143        3459           2         235        3569
Swap:             99           0          99

Openbox というデスクトップ環境のほうが省メモリであると海外のブログで読んだので変えてみたら以下のような感じ。

$ free -m
               total        used        free      shared  buff/cache   available
Mem:            3839          92        3538           0         207        3622
Swap:             99           0          99

というわけで、この記事では Openbox を使用します。

Raspbian のイメージを作成

OS のイメージは Raspberry Pi Imager で作成した。

当初は Raspberry Pi Lite でやろうとしたけど、あれこれ試してるうちに、ここで頑張ってもあんま意味ねーなと思えてきたので、普通に Raspberry Pi OS (32-bit) を選んだ。

SSH 及び Wifi については、Raspberry Pi Imager で、CTRL + SHIFT + X で表示される画面で、あらかじめ設定した。

設定

Raspberry Pi に SSH でログインしたあと、以下のようなコマンドを順番に実行した。

まず、アップデート。

sudo apt update
sudo apt upgrade -y

Scratch などの不要なパッケージを削除。

sudo apt purge wolfram-engine scratch nuscratch sonic-pi idle3 smartsim java-common libreoffice* -y

今回は、キオスク端末っぽく使用したいので、マウスカーソルを非表示にしたいので、unclutter というツールをインストール。

sudo apt install unclutter -y

掃除。

sudo apt clean
sudo apt autoremove -y

デスクトップ環境を設定するための設定ファイルを置くディレクトリをホームディレクトリ内に作成。

mkdir -p ~/.config/lxsession/LXDE-pi
mkdir -p ~/.config/openbox

デスクトップ環境を Openbox に変えるための設定。

echo "@openbox-session" > ~/.config/lxsession/LXDE-pi/autostart

Openbox の設定。

  • スリープとかスクリーンセーバーとかキオスク端末では不要なのでオフにする。
  • unclutter でマウスカーソルを非表示に。
  • Chromium を自動的に起動。
cat <<EOS > ~/.config/openbox/autostart
xset -dpms &     # Disable DPMS (Energy Star) features
xset s off &     # Disable screensaver
xset s noblank & # Don't blank video device
unclutter -idle 0 &
chromium-browser --noerrdialogs --disable-infobars --kiosk https://get.webgl.org/
EOS

最後に再起動。

sudo shutdown -r now

おまけ

僕は、GitHub Gist さんに上のコマンドを保存して以下のような感じで実行した。

curl https://gist.github.com/xxxx | bash

注意:

  • 上のシェルスクリプトでは、タッチディスプレイのドライバのインストールもしていますので注意。
  • デフォルトのパスワードの警告が出ないようにするための処理も入っているので注意。

あと、Chromium 起動後に https://get.webgl.org/ を開くようにしているのですが、Raspberry Pi の Chromium ってデフォルトでは WebGL が使えないのですね。。。汗

2022/1/5 追記

Matchbox というウインドウマネージャーを使うとよさそうだったのでそちらで試してみた。

その場合は、sudo apt install matchbox-window-manager したあとで ~/.config/lxsession/LXDE-pi/autostart に以下のように記述する。

@xset s off
@xset -dpms
@xset s noblank

@matchbox-window-manager
@chromium-browser --noerrdialogs --disable-infobars --gpu --gpu-launcher --in-process-gpu --ignore-gpu-blacklist --ignore-gpu-blocklist --kiosk https://miya0001.github.io/map/
9
9
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
9