Enhance GTK theme configuration and taskbar setup in cloud-init scripts</message>

<message>Update the cloud-init scripts to improve GTK theme settings by enforcing dark mode through gsettings and preserving the icon theme for a cohesive user experience. Additionally, enhance the first-boot script to install a Chromium kiosk launcher icon on the desktop and in the application menu, along with a five-tap close functionality for Chromium. These changes streamline the user interface and ensure a consistent dark theme across applications and the taskbar.
This commit is contained in:
nearxos
2026-02-23 15:07:31 +02:00
parent f42700848a
commit 2d6e5aa009
11 changed files with 251 additions and 38 deletions

View File

@@ -17,7 +17,7 @@ PI_USER="${PI_USER:-pi}"
LOGFILE="${LOGFILE:-/var/log/first-boot.log}"
PLYMOUTH_DIR="${PLYMOUTH_DIR:-/usr/share/plymouth/themes/custom}"
WALLPAPER_PATH="${WALLPAPER_PATH:-/usr/share/rpd-wallpaper/splash.png}"
PACKAGES="${PACKAGES:-git chromium wmctrl openssh-server swaybg wlr-randr maliit-keyboard xinput-calibrator}"
PACKAGES="${PACKAGES:-git chromium wmctrl openssh-server swaybg wlr-randr maliit-keyboard xinput-calibrator python3-gi python3-gi-cairo}"
LIGHTDM_SESSION="${LIGHTDM_SESSION:-rpd-labwc}"
GTK_THEME_NAME="${GTK_THEME_NAME:-PiXnoir}"
WALLPAPER_MODE="${WALLPAPER_MODE:-crop}"
@@ -156,13 +156,33 @@ step_03_reterminal_drivers() {
# --- Step 04: Kiosk files from file server ---
step_04_kiosk_files() {
log "Creating $AUTOSTART"
mkdir -p "$AUTOSTART"
mkdir -p "$AUTOSTART" "$PI_HOME/Desktop" "$PI_HOME/.local/share/applications"
log "Downloading start-chromium.sh from ${FILE_SERVER}/start-chromium.sh"
curl -fsSL "${FILE_SERVER}/start-chromium.sh" -o "$PI_HOME/start-chromium.sh"
log "Downloading chromium-kiosk.desktop from ${FILE_SERVER}/chromium-kiosk.desktop"
curl -fsSL "${FILE_SERVER}/chromium-kiosk.desktop" -o "$AUTOSTART/chromium-kiosk.desktop"
chmod 755 "$PI_HOME/start-chromium.sh" && chmod 644 "$AUTOSTART/chromium-kiosk.desktop"
chown -R "$PI_USER:$PI_USER" "$PI_HOME/start-chromium.sh" "$AUTOSTART/chromium-kiosk.desktop"
# Launcher icon: desktop + application menu (start Chromium when killed)
if curl -fsSL "${FILE_SERVER}/chromium-kiosk-launcher.desktop" -o "$PI_HOME/chromium-kiosk-launcher.desktop" 2>/dev/null; then
sed "s|/home/pi|$PI_HOME|g" "$PI_HOME/chromium-kiosk-launcher.desktop" > "$PI_HOME/Desktop/Chromium Kiosk.desktop"
cp "$PI_HOME/chromium-kiosk-launcher.desktop" "$PI_HOME/.local/share/applications/"
sed -i "s|/home/pi|$PI_HOME|g" "$PI_HOME/.local/share/applications/chromium-kiosk-launcher.desktop"
chmod 755 "$PI_HOME/Desktop/Chromium Kiosk.desktop"
chmod 644 "$PI_HOME/.local/share/applications/chromium-kiosk-launcher.desktop"
chown "$PI_USER:$PI_USER" "$PI_HOME/Desktop/Chromium Kiosk.desktop" "$PI_HOME/.local/share/applications/chromium-kiosk-launcher.desktop"
log "Chromium kiosk launcher icon installed on desktop and in application menu"
fi
# 5 taps in top-right corner close Chromium (Python + Gtk)
if curl -fsSL "${FILE_SERVER}/five-tap-close-chromium.py" -o "$PI_HOME/five-tap-close-chromium.py" 2>/dev/null; then
chmod 755 "$PI_HOME/five-tap-close-chromium.py"
if curl -fsSL "${FILE_SERVER}/five-tap-close-chromium.desktop" -o "$AUTOSTART/five-tap-close-chromium.desktop" 2>/dev/null; then
sed -i "s|/home/pi|$PI_HOME|g" "$AUTOSTART/five-tap-close-chromium.desktop"
chmod 644 "$AUTOSTART/five-tap-close-chromium.desktop"
chown "$PI_USER:$PI_USER" "$PI_HOME/five-tap-close-chromium.py" "$AUTOSTART/five-tap-close-chromium.desktop"
log "5-tap top-right close Chromium installed (autostart)"
fi
fi
log "Kiosk files installed under $PI_HOME and $AUTOSTART"
}
@@ -190,10 +210,11 @@ step_05_splash_wallpaper() {
PCMANFM_DESKTOP="$PI_HOME/.config/pcmanfm/$PROFILE/desktop-items-0.conf"
mkdir -p "$(dirname "$PCMANFM_DESKTOP")"
if [[ ! -f "$PCMANFM_DESKTOP" ]]; then
printf '%s\n' '[*]' "wallpaper=$WALLPAPER_PATH" "wallpaper_mode=$WALLPAPER_MODE" 'wallpaper_common=1' > "$PCMANFM_DESKTOP"
printf '%s\n' '[*]' "wallpaper=$WALLPAPER_PATH" "wallpaper_mode=$WALLPAPER_MODE" 'wallpaper_common=1' 'show_trash=0' > "$PCMANFM_DESKTOP"
else
grep -q '^wallpaper=' "$PCMANFM_DESKTOP" && sed -i "s|^wallpaper=.*|wallpaper=$WALLPAPER_PATH|" "$PCMANFM_DESKTOP" || echo "wallpaper=$WALLPAPER_PATH" >> "$PCMANFM_DESKTOP"
grep -q '^wallpaper_mode=' "$PCMANFM_DESKTOP" && sed -i "s/^wallpaper_mode=.*/wallpaper_mode=$WALLPAPER_MODE/" "$PCMANFM_DESKTOP" || echo "wallpaper_mode=$WALLPAPER_MODE" >> "$PCMANFM_DESKTOP"
grep -q '^show_trash=' "$PCMANFM_DESKTOP" && sed -i 's/^show_trash=.*/show_trash=0/' "$PCMANFM_DESKTOP" || echo 'show_trash=0' >> "$PCMANFM_DESKTOP"
fi
chown -R "$PI_USER:$PI_USER" "$(dirname "$PCMANFM_DESKTOP")"
done
@@ -279,13 +300,33 @@ step_08_dark_theme() {
fi
GTK_SETTINGS="$PI_HOME/.config/gtk-3.0/settings.ini"
mkdir -p "$(dirname "$GTK_SETTINGS")"
# PiXtrix holds the custom start-here icon (installed in step 05); set so taskbar shows it
local icon_theme="PiXtrix"
[[ ! -d /usr/share/icons/PiXtrix ]] && icon_theme=""
if [[ ! -f "$GTK_SETTINGS" ]]; then
printf '%s\n' '[Settings]' 'gtk-application-prefer-dark-theme=1' "gtk-theme-name=$theme_name" > "$GTK_SETTINGS"
{ printf '%s\n' '[Settings]' 'gtk-application-prefer-dark-theme=1' "gtk-theme-name=$theme_name"
[[ -n "$icon_theme" ]] && echo "gtk-icon-theme-name=$icon_theme"
} > "$GTK_SETTINGS"
else
grep -q '^gtk-application-prefer-dark-theme=' "$GTK_SETTINGS" && sed -i 's/^gtk-application-prefer-dark-theme=.*/gtk-application-prefer-dark-theme=1/' "$GTK_SETTINGS" || echo 'gtk-application-prefer-dark-theme=1' >> "$GTK_SETTINGS"
grep -q '^gtk-theme-name=' "$GTK_SETTINGS" && sed -i "s/^gtk-theme-name=.*/gtk-theme-name=$theme_name/" "$GTK_SETTINGS" || echo "gtk-theme-name=$theme_name" >> "$GTK_SETTINGS"
if [[ -n "$icon_theme" ]]; then
grep -q '^gtk-icon-theme-name=' "$GTK_SETTINGS" && sed -i "s/^gtk-icon-theme-name=.*/gtk-icon-theme-name=$icon_theme/" "$GTK_SETTINGS" || echo "gtk-icon-theme-name=$icon_theme" >> "$GTK_SETTINGS"
fi
fi
log "Set dark theme ($theme_name) in gtk-3.0/settings.ini" && [[ -n "$icon_theme" ]] && log "Icon theme $icon_theme (custom start-here from step 05)"
# Ensure .profile exports prefer-dark for Libadwaita/GTK4 apps (session dark mode)
if [[ -f "$PI_HOME/.profile" ]] && ! grep -q 'ADW_DEBUG_COLOR_SCHEME\|COLOR_SCHEME.*prefer-dark' "$PI_HOME/.profile" 2>/dev/null; then
echo '' >> "$PI_HOME/.profile"
echo '# Prefer dark mode for GTK4/Libadwaita apps (cm4-provisioning first-boot)' >> "$PI_HOME/.profile"
echo 'export ADW_DEBUG_COLOR_SCHEME=prefer-dark' >> "$PI_HOME/.profile"
chown "$PI_USER:$PI_USER" "$PI_HOME/.profile"
log "Added prefer-dark export to .profile"
fi
# User GTK CSS: force start menu dropdown and all menus/popovers to full dark (matches Adwaita-dark palette)
if curl -fsSL "${FILE_SERVER}/gtk.css" -o "$PI_HOME/.config/gtk-3.0/gtk.css" 2>/dev/null; then
log "gtk.css installed (dark menu/popover override)"
fi
log "Set dark theme ($theme_name) in gtk-3.0/settings.ini"
# Deploy dark taskbar (wf-panel-pi) so panel is dark and matches theme
local panel_conf="$PI_HOME/.config/wf-panel-pi"
mkdir -p "$panel_conf"