Skip to content

Instantly share code, notes, and snippets.

@gingkapls
Created December 21, 2020 14:08
Show Gist options
  • Save gingkapls/33f7567900a32ceed4b27f0eae1ffcd8 to your computer and use it in GitHub Desktop.
Save gingkapls/33f7567900a32ceed4b27f0eae1ffcd8 to your computer and use it in GitHub Desktop.
Wayland recording with waybar indicator
"custom/wf-recorder": {
"format": "{}",
"interval": "once",
"exec": "echo ''",
"tooltip": "false",
"exec-if": "pgrep 'wf-recorder'",
"on-click": "exec $HOME/.scripts/wlrecord.sh",
"signal": 8
}
#custom-wf-recorder {
padding: 0 20px;
color: @base07;
border-bottom: 4px solid @base01;
background-color: @base00;
}
#!/bin/sh
active=$(pacmd list-sources | awk 'c&&!--c;/* index*/{c=1}' | awk '{gsub(/<|>/,"",$0); print $NF}')
filename=$(date +%F_%T.mkv)
echo active sink: $active
echo $filename
if [ -z $(pgrep wf-recorder) ];
then notify-send "Recording Started ($active)"
if [ "$1" == "-s" ]
then wf-recorder -f $HOME/Videos/Recordings/$filename -a "$active" -g "$(slurp -c "#FFFFFF")" >/dev/null 2>&1 &
sleep 2
while [ ! -z $(pgrep -x slurp) ]; do wait; done
pkill -RTMIN+8 waybar
else if [ "$1" == "-w" ]
then wf-recorder -f $HOME/Videos/Recordings/$filename -a "$active" -g "$(swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | slurp -c "#FFFFFF" )" >/dev/null 2>&1 &
sleep 2
while [ ! -z $(pgrep -x slurp) ]; do wait; done
pkill -RTMIN+8 waybar
else
wf-recorder -f $HOME/Videos/Recordings/$filename -a "$active" >/dev/null 2>&1 &
pkill -RTMIN+8 waybar
fi
fi
else
killall -s SIGINT wf-recorder
notify-send "Recording Complete"
while [ ! -z $(pgrep -x wf-recorder) ]; do wait; done
pkill -RTMIN+8 waybar
name="$(zenity --entry --text "enter a filename")"
perl-rename "s/\.(mkv|mp4)$/ $name $&/" $(ls -d $HOME/Videos/Recordings/* -t | head -n1)
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment