···11+#!/bin/bash
22+33+# Docker Compose Windows VM Launcher
44+# Starts Windows VM via Docker and connects with RDP
55+# When RDP closes, docker-compose will also stop
66+77+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"
88+RDP_COMMAND="rdesktop -g 1440x900 -P -z -x l -r sound:off -u docker 127.0.0.1:3389 -p admin"
99+1010+echo "Starting Windows VM..."
1111+1212+# Change to script directory where docker-compose.yml is located
1313+cd "$SCRIPT_DIR" || {
1414+ echo "Error: Could not change to $SCRIPT_DIR"
1515+ exit 1
1616+}
1717+1818+# Function to handle cleanup
1919+cleanup() {
2020+ echo "Shutting down Windows VM..."
2121+ docker-compose down
2222+ exit 0
2323+}
2424+2525+# Set up signal handlers
2626+trap cleanup SIGTERM SIGINT
2727+2828+# Start docker-compose in foreground with a background process
2929+docker-compose up &
3030+COMPOSE_PID=$!
3131+3232+# Wait for RDP port to be available and RDP service to be ready
3333+echo "Waiting for RDP port to open..."
3434+while ! nc -z 127.0.0.1 3389; do
3535+ echo " Port 3389 not ready yet..."
3636+ sleep 10
3737+3838+ # Check if docker-compose process is still running
3939+ if ! kill -0 $COMPOSE_PID 2>/dev/null; then
4040+ echo "Docker Compose process died unexpectedly"
4141+ exit 1
4242+ fi
4343+done
4444+4545+echo "Port 3389 is open, waiting for Windows VM to fully initialize..."
4646+echo "This can take 2-3 minutes for Windows to boot completely..."
4747+4848+# Additional wait for Windows to fully boot and RDP service to be ready
4949+sleep 60
5050+5151+# Test RDP connection availability
5252+echo "Testing RDP connection..."
5353+timeout 10 rdesktop -g 640x480 -u docker 127.0.0.1:3389 -p admin 2>/dev/null
5454+if [ $? -ne 0 ]; then
5555+ echo "RDP not fully ready yet, waiting another 30 seconds..."
5656+ sleep 30
5757+fi
5858+5959+echo "Starting RDP connection..."
6060+echo "When you close RDP, the Windows VM will automatically shut down."
6161+6262+# Start RDP in foreground - when it exits, cleanup will run
6363+$RDP_COMMAND
6464+6565+# If RDP exits, cleanup
6666+cleanup
···11+[Desktop Entry]
22+Name=Windows VM
33+Comment=Start Windows VM via Docker and connect with RDP
44+Exec=uwsm app -- /home/sspaeti/.config/hypr/sspaeti/windows-ms/start-windows.sh
55+Icon=computer
66+Terminal=false
77+Type=Application
88+Categories=System;Virtualization;