diff --git a/.github/workflows/take_screenshot.yml b/.github/workflows/take_screenshot.yml index 0b374b3..a075e5b 100644 --- a/.github/workflows/take_screenshot.yml +++ b/.github/workflows/take_screenshot.yml @@ -49,16 +49,21 @@ jobs: cargo run --release > cargo.log 2>&1 & sleep 10 cat cargo.log - osascript -e 'tell application "System Events" to tell process "infoskjerm" to set frontmost to true' - osascript -e 'delay 10' - WINDOW_ID=$(osascript -e 'tell application "System Events" to return id of window of process "infoskjerm"') - echo "Window ID: $WINDOW_ID" # Print the window ID - screencapture -l$WINDOW_ID screenshot.png + window_info=$(osascript -e 'tell application "System Events" to tell process "infoskjerm" to get {position, size} of window 1') + x=$(echo $window_info | cut -d, -f1) + y=$(echo $window_info | cut -d, -f2) + w=$(echo $window_info | cut -d, -f3) + h=$(echo $window_info | cut -d, -f4) + + rectangle="${x},${y},${w},${h}" + rectangle=$(echo $rectangle | tr -d ' ') + screencapture -R$rectangle screenshot.png + - name: Commit and push screenshot run: | git config --local user.email "action@github.com" git config --local user.name "GitHub Action" - git add . - git commit -m "Add screenshot" -a + git add screenshot.png + git commit -m "Add updated screenshot" -a git push \ No newline at end of file