diff --git a/setup.sh b/setup.sh deleted file mode 100644 index 33843eb..0000000 --- a/setup.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/ash - -### run as root - -apk update -# Wayland, Labwc, DBus and Foot-Terminal -apk add wayland labwc foot xterm dbus - -apk add seatd -rc-update add seatd -rc-service seatd start - -adduser USER seat - -apk add cargo wayland-dev libxkbcommon-dev - -cargo install wdotool - -echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.profile -source ~/.profile \ No newline at end of file diff --git a/setup_wayland.sh b/setup_wayland.sh new file mode 100644 index 0000000..78e09ed --- /dev/null +++ b/setup_wayland.sh @@ -0,0 +1,117 @@ +script_content = """#!/bin/sh +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 + +# 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" + +# 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. ${C_BOLD}wdotool${C_RESET} wurde erfolgreich unter ${C_YELLOW}/usr/local/bin/wdotool${C_RESET} installiert." +echo -e "2. Starte die VM neu oder logge dich aus." +echo -e "3. Melde dich als Benutzer ${C_BOLD}'$TARGET_USER'${C_RESET} auf ${C_BOLD}TTY1${C_RESET} an." +echo -e "4. Wayland startet vollautomatisch und öffnet das Foot-Terminal." +echo -e "5. Teste die Automatisierung dort mit: ${C_CYAN}sleep 2 && wdotool type \"Hallo\"${C_RESET}\\n" +""" + +with open("setup_wayland.sh", "w") as f: + f.write(script_content) + +print("File generated successfully.") \ No newline at end of file