Files
reterminal-dm4/emmc-provisioning/cloud-init/fileserver/set-rotation-at-login.sh
nearxos c91cf6dd05 Update first-boot configuration and scripts for enhanced kiosk functionality</message>
<message>Modify the first-boot configuration to include the gir1.2-gtklayershell-0.1 package for improved GTK layer shell support. Update the first-boot script to enhance the portal status reporting with connection timeouts. Additionally, implement a restart mechanism for the kanshi service in rotation scripts to ensure immediate application of configuration changes. Introduce a Chromium kiosk extension to disable text selection, improving user experience in kiosk mode. These changes streamline the setup process and enhance the overall functionality of the kiosk environment.
2026-02-23 18:07:14 +02:00

49 lines
2.4 KiB
Bash

#!/bin/bash
# Revision: 2
# Set screen rotation via kanshi (same as Control Center). Reads video=DSI-1:rotate=N
# from kernel cmdline and writes ~/.config/kanshi/config. Kanshi auto-reloads when the file changes.
# Also sets GTK dark theme (PiXnoir / Adwaita-dark). Runs from autostart when user pi logs in; does not remove itself.
ROTATE="270"
for f in /boot/firmware/cmdline.txt /boot/cmdline.txt; do
[[ -f "$f" ]] || continue
val=$(grep -o 'video=DSI-1:rotate=[0-9]*' "$f" 2>/dev/null | head -1)
val="${val#*rotate=}"
[[ "$val" =~ ^(90|180|270)$ ]] && ROTATE="$val" && break
done
KANSHI_DIR="$HOME/.config/kanshi"
KANSHI_CONFIG="$KANSHI_DIR/config"
mkdir -p "$KANSHI_DIR"
cat > "$KANSHI_CONFIG" << EOF
profile {
output DSI-1 enable scale 1.000000 mode 800x1280@60.000 position 0,0 transform $ROTATE
}
EOF
# Restart kanshi so the config is applied immediately
if pgrep -u "$(id -u)" kanshi >/dev/null 2>&1; then
pkill -u "$(id -u)" kanshi 2>/dev/null
sleep 0.3
fi
nohup /usr/bin/kanshi >/dev/null 2>&1 &
# Set GTK dark theme (same as first-boot step 08) and force dark mode via gsettings
GTK_THEME_NAME="PiXnoir"
[[ -d /usr/share/themes/Adwaita-dark ]] && ! [[ -d /usr/share/themes/PiXnoir ]] && GTK_THEME_NAME="Adwaita-dark"
GTK_SETTINGS="$HOME/.config/gtk-3.0/settings.ini"
mkdir -p "$(dirname "$GTK_SETTINGS")"
if [[ ! -f "$GTK_SETTINGS" ]]; then
printf '%s\n' '[Settings]' 'gtk-application-prefer-dark-theme=1' "gtk-theme-name=$GTK_THEME_NAME" > "$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=$GTK_THEME_NAME/" "$GTK_SETTINGS" || echo "gtk-theme-name=$GTK_THEME_NAME" >> "$GTK_SETTINGS"
fi
# Force dark mode system-wide (GNOME/GTK apps that read gsettings)
if command -v gsettings >/dev/null 2>&1; then
gsettings set org.gnome.desktop.interface gtk-theme "$GTK_THEME_NAME" 2>/dev/null || true
gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark' 2>/dev/null || true
fi
# Preserve icon theme (PiXtrix = custom start-here)
if [[ -d /usr/share/icons/PiXtrix ]]; then
grep -q '^gtk-icon-theme-name=' "$GTK_SETTINGS" && sed -i 's/^gtk-icon-theme-name=.*/gtk-icon-theme-name=PiXtrix/' "$GTK_SETTINGS" || echo 'gtk-icon-theme-name=PiXtrix' >> "$GTK_SETTINGS"
fi