#!/bin/bash set -e # Farben für eine schöne Ausgabe C_GREEN='\033[1;32m' C_CYAN='\033[1;36m' C_YELLOW='\033[1;33m' C_RED='\033[1;31m' C_RESET='\033[0m' echo -e "${C_CYAN}====================================================" echo -e " J.A.R.V.I.S. - Alpine Wayland & wdotool Setup" echo -e "====================================================${C_RESET}" # 1. Prüfen, ob das Skript als root läuft if [ "$(id -u)" -ne 0 ]; then echo -e "${C_RED}Fehler: Dieses Skript muss als root ausgeführt werden!${C_RESET}" exit 1 fi # 2. Repositories aktualisieren und Basispakete installieren echo -e "\n${C_GREEN}[1/6] Installiere Systempakete (Wayland, Labwc, Rust)...${C_RESET}" apk update apk add wayland labwc foot dbus seatd cargo wayland-dev libxkbcommon-dev build-base bash nano ttf-dejavu ttf-liberation font-noto # 3. seatd aktivieren und starten (wichtig für Grafik- und Input-Rechte) echo -e "\n${C_GREEN}[2/6] Konfiguriere und starte den seatd-Dienst...${C_RESET}" rc-update add seatd default rc-service seatd start || true # 4. Benutzer abfragen und Gruppen zuweisen echo -e "\n${C_GREEN}[3/6] Benutzerkonfiguration...${C_RESET}" if [ -z "$TARGET_USER" ]; then echo -n "Für welchen Benutzernamen soll Wayland eingerichtet werden? " read TARGET_USER fi # Falls der User noch nicht existiert, erstellen wir ihn if ! id "$TARGET_USER" >/dev/null 2>&1; then echo -e "${C_YELLOW}Benutzer '$TARGET_USER' existiert nicht. Erstelle Benutzer...${C_RESET}" adduser -D -g "" "$TARGET_USER" echo -e "${C_YELLOW}Bitte lege ein Passwort für '$TARGET_USER' fest:${C_RESET}" passwd "$TARGET_USER" fi # Rechte für Hardware-Zugriff ohne root vergeben addgroup "$TARGET_USER" seat addgroup "$TARGET_USER" video || true addgroup "$TARGET_USER" input || true # 5. wdotool global für das gesamte System installieren echo -e "\n${C_GREEN}[4/6] Kompiliere und installiere wdotool global...${C_RESET}" echo -e "${C_YELLOW}(Das kann beim ersten Mal 1-2 Minuten dauern, da Cargo die Abhängigkeiten baut)${C_RESET}" # Installiert das Binary direkt sauber nach /usr/local/bin/wdotool cargo install --root /usr/local wdotool # 6. Minimale Labwc-Konfiguration für den User anlegen (Openbox-kompatibel) USER_HOME=$(eval echo ~$TARGET_USER) LABWC_CONFIG_DIR="$USER_HOME/.config/labwc" echo -e "\n${C_GREEN}[5/6] Erstelle Labwc-Konfigurationsdateien für '$TARGET_USER'...${C_RESET}" mkdir -p "$LABWC_CONFIG_DIR" # Minimales Rechtsklick-Menü erstellen cat << 'EOF' > "$LABWC_CONFIG_DIR/menu.xml" EOF # Autostart-Skript für Labwc anlegen (startet direkt das neue Terminal) cat << 'EOF' > "$LABWC_CONFIG_DIR/autostart" #!/bin/sh # Hier wird später dein J.A.R.V.I.S. Backend/Dashboard geladen foot & EOF chmod +x "$LABWC_CONFIG_DIR/autostart" # Eigentümerrechte der Konfiguration an den User übergeben chown -R "$TARGET_USER":"$TARGET_USER" "$USER_HOME/.config" # 7. .profile patchen, damit Labwc direkt beim TTY1-Login startet PROFILE_FILE="$USER_HOME/.profile" if ! grep -q "labwc" "$PROFILE_FILE" 2>/dev/null; then echo -e "\n${C_GREEN}[6/6] Richte automatischen Desktop-Start in .profile ein...${C_RESET}" cat << 'EOF' >> "$PROFILE_FILE" # XDG Runtime Directory für Wayland initialisieren if [ -z "$XDG_RUNTIME_DIR" ]; then export XDG_RUNTIME_DIR=/tmp/$(id -u)-runtime-dir if [ ! -d "$XDG_RUNTIME_DIR" ]; then mkdir -p "$XDG_RUNTIME_DIR" chmod 0700 "$XDG_RUNTIME_DIR" fi fi # Startet Wayland/Labwc automatisch, wenn du dich auf TTY1 einloggst if [ -z "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ] && [ "$(tty)" = "/dev/tty1" ]; then exec dbus-run-session labwc fi EOF fi echo -e "\n${C_CYAN}====================================================" echo -e "${C_GREEN}✅ Setup erfolgreich abgeschlossen!${C_CYAN}" echo -e "====================================================${C_RESET}" echo -e "1. wdotool wurde erfolgreich unter /usr/local/bin/wdotool installiert." echo -e "2. Starte die VM neu oder logge dich aus." echo -e "3. Melde dich als Benutzer '$TARGET_USER' auf TTY1 an." echo -e "4. Wayland startet vollautomatisch und öffnet das Foot-Terminal."