-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup_xserver.sh
More file actions
executable file
·107 lines (96 loc) · 3.04 KB
/
setup_xserver.sh
File metadata and controls
executable file
·107 lines (96 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
# X Server Setup Script for Computer Use MCP
echo "Computer Use MCP - X Server Setup"
echo "================================="
echo
# Detect WSL
if grep -q Microsoft /proc/version; then
echo "✓ WSL2 detected"
WSL_MODE=true
HOST_IP=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}')
echo " Windows host IP: $HOST_IP"
else
echo "✗ Not running in WSL"
WSL_MODE=false
fi
# Check current DISPLAY
echo
echo "Current Environment:"
echo " DISPLAY: ${DISPLAY:-Not set}"
# Test X server connectivity
echo
echo "Testing X Server Connectivity:"
if timeout 3 xset q &>/dev/null; then
echo "✓ X server is accessible at $DISPLAY"
X_AVAILABLE=true
else
echo "✗ No X server accessible"
X_AVAILABLE=false
fi
# Check for required packages
echo
echo "Checking Required Packages:"
PACKAGES=("xorg" "xvfb" "x11-apps" "x11-utils" "xdotool" "scrot" "imagemagick")
MISSING_PACKAGES=()
for pkg in "${PACKAGES[@]}"; do
if dpkg -l | grep -q "^ii $pkg"; then
echo "✓ $pkg installed"
else
echo "✗ $pkg not installed"
MISSING_PACKAGES+=($pkg)
fi
done
# Installation recommendations
if [ ${#MISSING_PACKAGES[@]} -gt 0 ]; then
echo
echo "Missing packages detected. Install with:"
echo " sudo apt-get update"
echo " sudo apt-get install -y ${MISSING_PACKAGES[@]}"
fi
# WSL-specific recommendations
if [ "$WSL_MODE" = true ] && [ "$X_AVAILABLE" = false ]; then
echo
echo "WSL2 X Server Setup Instructions:"
echo "================================="
echo "1. Install X server on Windows (choose one):"
echo " - VcXsrv: https://sourceforge.net/projects/vcxsrv/"
echo " - X410: Available in Microsoft Store (paid)"
echo " - Xming: https://sourceforge.net/projects/xming/"
echo
echo "2. Configure X server on Windows:"
echo " - Launch with 'Multiple windows' mode"
echo " - Disable access control (allow connections)"
echo " - Enable 'Disable access control' in settings"
echo
echo "3. Set DISPLAY in WSL2:"
echo " export DISPLAY=$HOST_IP:0.0"
echo
echo "4. Add to ~/.bashrc for persistence:"
echo " echo 'export DISPLAY=\$(cat /etc/resolv.conf | grep nameserver | awk '\''{print \$2}'\''):0.0' >> ~/.bashrc"
fi
# Virtual display option
echo
echo "Alternative: Virtual Display (Xvfb)"
echo "==================================="
echo "For headless operation without a real display:"
echo " Xvfb :99 -screen 0 1920x1080x24 -ac +extension GLX +render -noreset &"
echo " export DISPLAY=:99"
echo
echo "Or use the MCP tools:"
echo " - start_xserver tool to start virtual display"
echo " - xserver_status tool to check status"
# Test screenshot capability
echo
echo "Testing Screenshot Capability:"
if [ "$X_AVAILABLE" = true ]; then
if scrot /tmp/test_screenshot.png 2>/dev/null; then
echo "✓ Screenshot capture working"
rm -f /tmp/test_screenshot.png
else
echo "✗ Screenshot capture failed"
fi
else
echo "✗ Cannot test - no X server available"
fi
echo
echo "Setup check complete!"