Skip to content
赞赏-微信扫码

Kiosk - 信息亭终端

创建于: 2025-01-24

程序的 kiosk 模式,在软件领域通常指 信息亭、监控大屏 等全屏独占嵌入式终端界面的模式。

如果对兼容性有要求,或者有双屏拓展之类的高级需求。还是不要轻易尝试 wayland、weston。老老实实用 X11。

root 用户

启动 X 图形服务, 需要 root 权限. 目前是在 ~/.profile 中启动 X 图形服务. 所以开机要登录到 root 账号.

这么做是不太好,应该可以将 X 服务的启动 放在 user-systemd 中.

sh
sudo passwd root

开机进入命令行界面

sh
# 开机进入 命令行界面
systemctl set-default multi-user.target

# 开机进入 图形界面 , 用于系统出问题的时候(连不上网之类的), 能回到原来的 Ubuntu 桌面进行维护
# systemctl set-default graphical.target

开机免登录

sh
# 命令行界面, 开机免登录
# man agetty
# man login
# vi /etc/systemd/system/getty.target.wants/getty@tty1.service
[Service]
ExecStart=-/sbin/agetty -o '-p -- \\u' --noclear - $TERM 
ExecStart=-/sbin/agetty --autologin=root -o '-p -f root -- \\u' --noclear - $TERM 

TIP

这个配置的修改,在系统升级等操作后会被重置。

启动图形服务

sh
# vi ~/.profile
if pgrep -x xinit > /dev/null; then
    echo "xinit 已经在运行"
else
    xinit
fi

启动窗口管理器 + 目标程序

sh
# vi ~/.xinitrc
# 运行 vmware-horizon-client 远程桌面客户端
vmware-view -q -s example.com --enableMMR --save &
exec x-window-manager
sh
# 禁用自动息屏
xset s off -dpms

weston 方式

sh
apt install weston

weston 是一个基础的窗口管理程序,提供 桌面背景、状态栏、程序窗口、鼠标 等基础功能。

wayland 下用 weston,相当于 X11 下用 x-window-manager。

sh
# vi ~/.profile  
if pgrep -x weston > /dev/null; then
    echo "weston 已经在运行"
else
    export QT_QPA_PLATFORM=wayland
    weston
fi
sh
# vi ~/.config/weston.ini

[core]
# 不进入屏保界面
idle-time=0
# 兼容 x11 程序
xwayland=true

[shell]
# 纯黑背景。别设置成透明,不然鼠标和窗口可能会有残影。
background-color=0xff000000
# 不显示状态栏
panel-position=none

[input-method]
path=/usr/lib/x86_64-linux-gnu/weston-keyboard

[autolaunch]
# 需要较新的 weston 版本,才支持这个功能
path=/home/xx/a.py