update
This commit is contained in:
@@ -15,35 +15,57 @@ if [ ! -S "$MONITOR_SOCK" ]; then
|
||||
fi
|
||||
|
||||
mkdir -p "$SCREENSHOT_DIR"
|
||||
PPM_FILE="$SCREENSHOT_DIR/ecoos-$TIMESTAMP.ppm"
|
||||
PNG_FILE="$SCREENSHOT_DIR/ecoos-$TIMESTAMP.png"
|
||||
LATEST_FILE="$SCREENSHOT_DIR/latest.png"
|
||||
|
||||
echo "Taking screenshot..."
|
||||
echo "screendump $PPM_FILE" | socat - UNIX-CONNECT:"$MONITOR_SOCK"
|
||||
sleep 1
|
||||
# Screenshot all displays (video0, video1, video2)
|
||||
DISPLAYS="video0 video1 video2"
|
||||
SCREENSHOTS=()
|
||||
|
||||
# Check if PPM was created
|
||||
if [ ! -f "$PPM_FILE" ]; then
|
||||
echo "ERROR: Screenshot failed"
|
||||
exit 1
|
||||
fi
|
||||
echo "Taking screenshots of all displays..."
|
||||
|
||||
# Convert to PNG if imagemagick is available
|
||||
if command -v convert &> /dev/null; then
|
||||
convert "$PPM_FILE" "$PNG_FILE"
|
||||
rm "$PPM_FILE"
|
||||
for DISPLAY in $DISPLAYS; do
|
||||
PPM_FILE="$SCREENSHOT_DIR/ecoos-$TIMESTAMP-$DISPLAY.ppm"
|
||||
PNG_FILE="$SCREENSHOT_DIR/ecoos-$TIMESTAMP-$DISPLAY.png"
|
||||
|
||||
# Copy to latest.png
|
||||
cp "$PNG_FILE" "$LATEST_FILE"
|
||||
# Take screenshot of this display
|
||||
echo "screendump $PPM_FILE $DISPLAY" | socat - UNIX-CONNECT:"$MONITOR_SOCK" 2>/dev/null
|
||||
sleep 0.5
|
||||
|
||||
echo "Screenshot saved: $PNG_FILE"
|
||||
if [ -f "$PPM_FILE" ]; then
|
||||
# Convert to PNG if imagemagick is available
|
||||
if command -v convert &> /dev/null; then
|
||||
convert "$PPM_FILE" "$PNG_FILE"
|
||||
rm "$PPM_FILE"
|
||||
SCREENSHOTS+=("$PNG_FILE")
|
||||
echo " $DISPLAY: $PNG_FILE"
|
||||
else
|
||||
SCREENSHOTS+=("$PPM_FILE")
|
||||
echo " $DISPLAY: $PPM_FILE"
|
||||
fi
|
||||
else
|
||||
echo " $DISPLAY: (no output or not connected)"
|
||||
fi
|
||||
done
|
||||
|
||||
# Create a combined image if we have multiple screenshots and imagemagick
|
||||
if command -v convert &> /dev/null && [ ${#SCREENSHOTS[@]} -gt 1 ]; then
|
||||
COMBINED_FILE="$SCREENSHOT_DIR/ecoos-$TIMESTAMP-combined.png"
|
||||
LATEST_FILE="$SCREENSHOT_DIR/latest.png"
|
||||
|
||||
# Combine images horizontally
|
||||
convert "${SCREENSHOTS[@]}" +append "$COMBINED_FILE"
|
||||
cp "$COMBINED_FILE" "$LATEST_FILE"
|
||||
|
||||
echo ""
|
||||
echo "Combined screenshot: $COMBINED_FILE"
|
||||
echo "Also saved as: $LATEST_FILE"
|
||||
elif [ ${#SCREENSHOTS[@]} -eq 1 ]; then
|
||||
LATEST_FILE="$SCREENSHOT_DIR/latest.png"
|
||||
cp "${SCREENSHOTS[0]}" "$LATEST_FILE"
|
||||
echo ""
|
||||
echo "Also saved as: $LATEST_FILE"
|
||||
else
|
||||
echo "Screenshot saved: $PPM_FILE"
|
||||
echo "(Install imagemagick to auto-convert to PNG)"
|
||||
fi
|
||||
|
||||
# Keep only last 20 screenshots (excluding latest.png)
|
||||
# Keep only last 20 screenshot sets (excluding latest.png)
|
||||
cd "$SCREENSHOT_DIR"
|
||||
ls -t ecoos-*.png 2>/dev/null | tail -n +21 | xargs -r rm -f
|
||||
ls -t ecoos-*-combined.png 2>/dev/null | tail -n +21 | xargs -r rm -f
|
||||
ls -t ecoos-*-video*.png 2>/dev/null | tail -n +61 | xargs -r rm -f
|
||||
|
||||
Reference in New Issue
Block a user