diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 8e5c623..5405911 100644 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -8,6 +8,15 @@ SOURCE_DIR="$PROJECT_DIR/dist/car_ui" INSTALL_DIR="/opt/car_ui" SERVICE="car-ui.service" +DESKTOP_USER="cheykrym" +DESKTOP_DIR="/home/$DESKTOP_USER/Desktop" + +LAUNCHER_SOURCE="$PROJECT_DIR/system_configs/Return_to_Car_UI.desktop" +LAUNCHER_TARGET="$DESKTOP_DIR/Return_to_Car_UI.desktop" + +HELPER_SOURCE="$PROJECT_DIR/scripts/return-to-car-mode.sh" +HELPER_TARGET="/usr/local/bin/return-to-car-mode" + if [[ $EUID -ne 0 ]]; then echo "ERROR: deploy.sh must be run as root." echo @@ -24,6 +33,18 @@ if [[ ! -x "$SOURCE_DIR/car_ui" ]]; then exit 1 fi +if [[ ! -f "$LAUNCHER_SOURCE" ]]; then + echo "ERROR: Desktop launcher not found:" + echo " $LAUNCHER_SOURCE" + exit 1 +fi + +if [[ ! -f "$HELPER_SOURCE" ]]; then + echo "ERROR: Return-to-Car helper not found:" + echo " $HELPER_SOURCE" + exit 1 +fi + echo "==> Stopping $SERVICE" systemctl stop "$SERVICE" 2>/dev/null || true @@ -34,10 +55,31 @@ rm -rf "$INSTALL_DIR" mkdir -p "$INSTALL_DIR" cp -a "$SOURCE_DIR/." "$INSTALL_DIR/" +echo "==> Installing Return to Car UI helper" + +install -m 755 "$HELPER_SOURCE" "$HELPER_TARGET" + +echo "==> Installing desktop launcher" + +mkdir -p "$DESKTOP_DIR" + +install \ + -o "$DESKTOP_USER" \ + -g "$DESKTOP_USER" \ + -m 755 \ + "$LAUNCHER_SOURCE" \ + "$LAUNCHER_TARGET" + +# Mark launcher as trusted for the desktop environment. +sudo -u "$DESKTOP_USER" \ + DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$(id -u "$DESKTOP_USER")/bus" \ + gio set "$LAUNCHER_TARGET" metadata::trusted true 2>/dev/null || true + echo "==> Starting $SERVICE" systemctl start "$SERVICE" echo echo "==> Deployment complete" -echo " $INSTALL_DIR/car_ui" +echo " Application: $INSTALL_DIR/car_ui" +echo " Launcher: $LAUNCHER_TARGET" diff --git a/scripts/return-to-car-mode.sh b/scripts/return-to-car-mode.sh new file mode 100644 index 0000000..0e43612 --- /dev/null +++ b/scripts/return-to-car-mode.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +set -euo pipefail + +CAR_UI_BIN="/opt/car_ui/car_ui" + +if [[ ! -x "$CAR_UI_BIN" ]]; then + echo "ERROR: Car UI binary not found:" + echo " $CAR_UI_BIN" + exit 1 +fi + +systemctl disable --now getty@tty1.service +systemctl mask getty@tty1.service + +systemctl enable bt-unblock.service +systemctl enable car-ui.service + +systemctl set-default multi-user.target + +reboot diff --git a/system_configs/Return_to_Car_UI.desktop b/system_configs/Return_to_Car_UI.desktop index ad5516b..f504815 100755 --- a/system_configs/Return_to_Car_UI.desktop +++ b/system_configs/Return_to_Car_UI.desktop @@ -1,9 +1,9 @@ [Desktop Entry] Type=Application Name=Return to Car UI -Comment=Back to Automotive Interface -Exec=/opt/car_ui/car_ui -Icon=applications-system +Comment=Reboot into Car mode +Exec=pkexec /usr/local/bin/return-to-car-mode +Icon=system-reboot Terminal=false -Categories=Utility; +Categories=System; StartupNotify=false