update screen grab scripts to partially support wayland
This commit is contained in:
parent
728c410552
commit
427a0f9ec6
3 changed files with 41 additions and 16 deletions
|
@ -1,20 +1,27 @@
|
|||
#!/bin/bash
|
||||
|
||||
statusfile="/tmp/running_screen_recorder"
|
||||
STATUSFILE="/tmp/running_screen_recorder"
|
||||
# check for running instance, stop it and exit
|
||||
if [ -f $statusfile ]; then
|
||||
ffpid=$(<$statusfile)
|
||||
kill $ffpid
|
||||
rm $statusfile
|
||||
if [ -f $STATUSFILE ]; then
|
||||
FFPID=$(<$STATUSFILE)
|
||||
kill $FFPID
|
||||
rm $STATUSFILE
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# select area of screen
|
||||
slop=$(slop -f "%x %y %w %h %g %i" --color=0.8,0.4,1.0,1.0 -t 16) || exit 1
|
||||
read -r X Y W H G ID < <(echo $slop)
|
||||
if [ $XDG_SESSION_TYPE = 'wayland' ]; then
|
||||
SLURP=$(slurp -b#ff44ff22 -w0) || exit 1
|
||||
read -r POS DIMS < <(echo $SLURP)
|
||||
W=${DIMS%x*}
|
||||
H=${DIMS#*x}
|
||||
else
|
||||
SLOP=$(slop -f "%x,%y %w %h" --color=0.8,0.4,1.0,1.0 -t 16) || exit 1
|
||||
read -r POS W H< <(echo $SLOP)
|
||||
fi
|
||||
|
||||
videofile=$(xdg-user-dir VIDEOS)/sel_$(date "+%Y-%m-%d_%H.%M.%S").mp4
|
||||
logfile="/tmp/screen_recorder_ffmpeg.log"
|
||||
OUTPUT_FILE=$(xdg-user-dir VIDEOS)/sel_$(date "+%Y-%m-%d_%H.%M.%S").mp4
|
||||
LOGFILE="/tmp/screen_recorder_ffmpeg.log"
|
||||
|
||||
# make sure selection width and height is even
|
||||
# even video size needed for yuv420p format
|
||||
|
@ -22,10 +29,15 @@ logfile="/tmp/screen_recorder_ffmpeg.log"
|
|||
H=$(( $H - $H%2 ))
|
||||
W=$(( $W - $W%2 ))
|
||||
|
||||
# empty audio track to prevent videos showing up as "GIF" on certain platforms (mastodon)
|
||||
dummy_audio="-f lavfi -i anullsrc=cl=mono"
|
||||
|
||||
if [ $XDG_SESSION_TYPE = 'wayland' ]; then
|
||||
echo "fuck (todo figure out wayland ffmpeg shit)"
|
||||
# ffmpeg $video_settings -device /dev/dri/card1-re-fkms-grab -i - $OUTPUT_FILE 2> $LOGFILE &
|
||||
else
|
||||
ffmpeg -y $dummy_audio -video_size "$W"x"$H" -f x11grab -framerate 60 \
|
||||
-i $DISPLAY+$X,$Y -pix_fmt yuv420p $videofile 2> $logfile &
|
||||
|
||||
-i $DISPLAY+$POS -pix_fmt yuv420p $OUTPUT_FILE 2> $LOGFILE &
|
||||
fi
|
||||
# store pid so that recording can be stopped next time the script is run
|
||||
echo $! > $statusfile
|
||||
echo $! > $STATUSFILE
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
#!/bin/bash
|
||||
path=$(xdg-user-dir PICTURES)/screenshots/screen-$(date "+%Y-%m-%d_%H:%M:%S").png
|
||||
mkdir -p $(xdg-user-dir PICTURES)/screenshots
|
||||
|
||||
if [ $XDG_SESSION_TYPE = 'wayland' ]; then
|
||||
grim $path
|
||||
wl-copy -t image/png < $path
|
||||
else
|
||||
maim -u -o $path
|
||||
xclip -selection clipboard -target image/png -i $path
|
||||
fi
|
||||
|
||||
|
|
|
@ -1,2 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ $XDG_SESSION_TYPE = 'wayland' ]; then
|
||||
grim -g "$(slurp -b#ffff4411 -w0)" - | wl-copy -t image/png
|
||||
else
|
||||
maim -s -u --color=1.0,0.5,0.0,1.0 -t 16 | xclip -selection clipboard -t image/png
|
||||
fi
|
||||
|
||||
|
|
Loading…
Reference in a new issue