Browse Source

Add dw touch install command

Installs the touch app from scratch:
- Installs Qt/PySide6 system dependencies
- Clones dune-weaver-touch repo
- Creates Python venv and installs requirements
- Creates and enables systemd service

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
tuanchris 1 month ago
parent
commit
a07f1d0194
1 changed files with 65 additions and 0 deletions
  1. 65 0
      dw

+ 65 - 0
dw

@@ -242,12 +242,77 @@ cmd_touch() {
         status)
             sudo systemctl status dune-weaver-touch
             ;;
+        install)
+            local touch_dir="/home/pi/dune-weaver-touch"
+            local touch_repo="https://github.com/tuanchris/dune-weaver-touch"
+
+            echo -e "${BLUE}Installing touch app...${NC}"
+
+            # Install system dependencies for Qt/PySide6
+            echo "Installing system dependencies..."
+            sudo apt update
+            sudo apt install -y python3-venv python3-pip \
+                libxcb-cursor0 libxkbcommon0 libxcb-xinerama0 \
+                libxcb-icccm4 libxcb-image0 libxcb-keysyms1 \
+                libxcb-randr0 libxcb-render-util0 libxcb-shape0
+
+            # Clone or update repo
+            if [[ -d "$touch_dir" ]]; then
+                echo "Updating existing installation..."
+                cd "$touch_dir"
+                git pull
+            else
+                echo "Cloning touch app repository..."
+                git clone "$touch_repo" "$touch_dir"
+                cd "$touch_dir"
+            fi
+
+            # Create venv and install dependencies
+            echo "Setting up Python environment..."
+            python3 -m venv venv
+            source venv/bin/activate
+            pip install --upgrade pip
+            pip install -r requirements.txt
+            deactivate
+
+            # Create systemd service
+            echo "Creating systemd service..."
+            sudo tee /etc/systemd/system/dune-weaver-touch.service > /dev/null << EOF
+[Unit]
+Description=Dune Weaver Touch App
+After=network.target
+
+[Service]
+Type=simple
+User=pi
+WorkingDirectory=$touch_dir
+Environment=QT_QPA_PLATFORM=eglfs
+Environment=QT_QPA_EGLFS_INTEGRATION=eglfs_kms
+Environment=QT_QPA_EGLFS_KMS_CONFIG=$touch_dir/eglfs_config.json
+Environment=QML2_IMPORT_PATH=$touch_dir/venv/lib/python3.11/site-packages/PySide6/qml
+ExecStart=$touch_dir/venv/bin/python $touch_dir/main.py
+Restart=always
+RestartSec=5
+
+[Install]
+WantedBy=multi-user.target
+EOF
+
+            # Enable and start service
+            sudo systemctl daemon-reload
+            sudo systemctl enable dune-weaver-touch
+            sudo systemctl start dune-weaver-touch
+
+            echo -e "${GREEN}Touch app installed!${NC}"
+            echo "View logs with: dw touch logs"
+            ;;
         help|*)
             echo -e "${GREEN}Touch App Commands${NC}"
             echo ""
             echo "Usage: dw touch <command>"
             echo ""
             echo "Commands:"
+            echo "  install     Install touch app (clone, setup, enable service)"
             echo "  logs [N]    View logs (N lines or follow if omitted)"
             echo "  restart     Restart touch app"
             echo "  stop        Stop touch app"