Created
December 19, 2022 10:09
-
-
Save thesadabc/173bb76742e355f05a7ce47916feff6c to your computer and use it in GitHub Desktop.
设置ubutnu系统开机自启动Chromium浏览器,并进入Kiosk全屏模式
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 设置账号开机自动登录 | |
# 设置登录后自动运行 | |
# 在启动脚本中执行服务及打开kiosk模式的浏览器 | |
# 关闭锁屏与自动息屏等,也可以在系统设置中手动修改,问题不大 | |
# ubuntu1810以上不再使用unity,需要修改对应脚本,一搜一大把 | |
gsettings set org.gnome.desktop.screensaver lock-enabled false | |
gsettings set org.gnome.desktop.session idle-delay 0 | |
gsettings set org.gnome.desktop.background show-desktop-icons false | |
dconf write "/org/compiz/profiles/unity/plugins/unityshell/launcher-hide-mode" 1 | |
gsettings set com.ubuntu.update-notifier regular-auto-launch-interval 3650 | |
# 设置开机当前账号自动登录账号 | |
sudo sed -i -E 's/.*AutomaticLoginEnable .+/AutomaticLoginEnable = true/' /etc/gdm3/custom.conf | |
sudo sed -i -E "s/.*AutomaticLogin .+/AutomaticLogin = $USER/" /etc/gdm3/custom.conf | |
# 设置自启动, 也可以在系统startup应用中手动添加启动命令 | |
[[ -d $HOME/.config/autostart ]] || mkdir -p $HOME/.config/autostart/ | |
cat > $HOME/.config/autostart/xxxxxxxx.desktop << EOF | |
[Desktop Entry] | |
Type=Application | |
Exec=$HOME/startup.sh | |
Hidden=false | |
NoDisplay=false | |
X-GNOME-Autostart-enabled=true | |
Name=xxxxxxxx | |
Comment= | |
EOF | |
# 应用启动脚本,下次开机后就会自动登录账号,自动运行这个脚本,自动启动服务,自动打开浏览器全屏模式 | |
cat > $HOME/startup.sh << EOF | |
#!/bin/bash | |
# 启动服务 | |
python3 -m http.server 8080 & | |
serverpid=\$! | |
# 打开浏览器全屏模式 | |
sleep 5 | |
chromium-browser "http://localhost:8080" \ | |
--start-fullscreen \ | |
--kiosk \ | |
--incognito \ | |
--noerrdialogs \ | |
--disable-translate \ | |
--no-first-run \ | |
--fast \ | |
--fast-start \ | |
--disable-infobars \ | |
--disable-features=TranslateUI \ | |
--disk-cache-dir=/dev/null \ | |
--overscroll-history-navigation=0 \ | |
--disable-pinch \ | |
--password-store=basic \ | |
--autoplay-policy=no-user-gesture-required | |
# 浏览器关闭后同时关闭服务 | |
kill \$serverpid | |
wait | |
EOF | |
chmod a+x $HOME/startup.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment