-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworkspace-previews-capture.sh
More file actions
executable file
·39 lines (30 loc) · 1.25 KB
/
workspace-previews-capture.sh
File metadata and controls
executable file
·39 lines (30 loc) · 1.25 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
#!/usr/bin/env bash
SCREENSHOT_DIR="$HOME/stuff/pictures/workspace-previews"
mkdir -p "$SCREENSHOT_DIR"
# debug - verify we can write to the directory
touch "$SCREENSHOT_DIR/testfile" 2>/dev/null && rm "$SCREENSHOT_DIR/testfile" || {
echo "~ Cannot write to $SCREENSHOT_DIR"
exit 1
}
PREV_WS=$(hyprctl activeworkspace -j | jq -r '.id')
while true; do
CURRENT_WS=$(hyprctl activeworkspace -j | jq -r '.id')
if [[ "$CURRENT_WS" != "$PREV_WS" ]]; then
echo "~ Workspace changed to $CURRENT_WS"
# take screenshot directly to final filename
FINAL_FILE="$SCREENSHOT_DIR/${CURRENT_WS}.png"
OLD_MD5=$(md5sum "$FINAL_FILE" 2>/dev/null | cut -d' ' -f1)
hyprshot -m active --mode output -o "$SCREENSHOT_DIR" -f "${CURRENT_WS}.png" 2>/dev/null --silent;
# verify capture succeeded
if [[ -f "$FINAL_FILE" ]]; then
echo "~ Successfully saved $FINAL_FILE"
else
echo "~ All capture methods failed for workspace $CURRENT_WS"
# debug - list directory contents
echo "Directory contents:"
ls -la "$SCREENSHOT_DIR" || echo "~ Could not list directory"
fi
PREV_WS=$CURRENT_WS
fi
sleep 1
done