diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-12-24 13:54:03 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-12-24 13:54:03 +0900 |
| commit | 28e8bdf7f8286bd431b7f3b709e79f3827b31469 (patch) | |
| tree | 85b44eff6da4d8443198fb6e04dfb6ee55244588 /debian/.local/bin/screenshotactivewindow | |
| parent | 8470ff001befcfd0f626dea69a9e76d43aee0511 (diff) | |
updates
Diffstat (limited to 'debian/.local/bin/screenshotactivewindow')
| -rwxr-xr-x | debian/.local/bin/screenshotactivewindow | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/debian/.local/bin/screenshotactivewindow b/debian/.local/bin/screenshotactivewindow new file mode 100755 index 0000000..79365e0 --- /dev/null +++ b/debian/.local/bin/screenshotactivewindow @@ -0,0 +1,37 @@ +#!/bin/bash +set -eo pipefail + +pidfile=/tmp/screencast.lock + +if [ -e $pidfile ]; then + pid=$(cat $pidfile) + echo "Already running as ID $pid, now quitting" + rm $pidfile + kill -15 $pid + exit 0 +fi + +if [[ "$1" == "" ]]; then + echo "Usage: ${0##*/} <window-id>" + exit 2 +fi + +windowId=$1 +tmpFile=/tmp/screencast-$(date +%s).mkv +paletteFile=/tmp/palette-$(date +%s).png +gifFile=/tmp/screencast-$(date +%s).gif + +size=$(xdotool getwindowgeometry $windowId | grep Geometry | awk '{print $2}') +posX=$(xwininfo -id $windowId | grep 'Absolute upper-left X' | awk '{print $4}') +posY=$(xwininfo -id $windowId | grep 'Absolute upper-left Y' | awk '{print $4}') +pos="$posX,$posY" + +ffmpeg -hide_banner -loglevel info -f x11grab -show_region 1 -video_size $size -i :0+$pos $tmpFile & +ffPID=$! +echo $ffPID >$pidfile +wait $ffPID && echo + +ffmpeg -y -i $tmpFile -vf fps=10,palettegen $paletteFile +ffmpeg -i $tmpFile -i $paletteFile -filter_complex "paletteuse" $gifFile + +rm $paletteFile $tmpFile |
