forked from fmarier/user-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremote_screenshot
More file actions
executable file
·31 lines (25 loc) · 892 Bytes
/
remote_screenshot
File metadata and controls
executable file
·31 lines (25 loc) · 892 Bytes
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
#!/bin/bash
# TODO: make fwknop optional
if [ "z$1" = "z" ]; then
echo "Usage: $(basename "$0") hostname"
exit 1
fi
TARGET_HOST="$1"
TARGET_DISPLAY=":0.0"
# Take the screenshot
#fwknop --quiet --Last-host "$TARGET_HOST"
SCREENSHOT_FILE="$(ssh "$TARGET_HOST" mktemp screenshotXXXXXXXX).jpg"
stty -echo
# shellcheck disable=SC2029
ssh "$TARGET_HOST" rm "$(basename "$SCREENSHOT_FILE" .jpg)" \&\& sudo -S DISPLAY="$TARGET_DISPLAY" import -window root "$SCREENSHOT_FILE" || (stty echo && exit 2)
echo
stty echo
# Copy the screenshot over
OUTPUT_FILE="$(mktemp ./screenshotXXXXXXXX).jpg"
rm "$(basename "$OUTPUT_FILE" .jpg)"
#fwknop --quiet --Last-host "$TARGET_HOST"
scp "$TARGET_HOST:$SCREENSHOT_FILE" "$OUTPUT_FILE"
# Delete screenshot from remote server
#fwknop --quiet --Last-host "$TARGET_HOST"
# shellcheck disable=SC2029
ssh "$TARGET_HOST" sudo rm "$SCREENSHOT_FILE"