#!/bin/bash endrec () { killall -s SIGINT wf-recorder # beacon (the notif daemon) has no dunstctl; close the "recording started" # card via the freedesktop CloseNotification method instead. [ -n "$nid" ] && gdbus call --session --dest org.freedesktop.Notifications \ --object-path /org/freedesktop/Notifications \ --method org.freedesktop.Notifications.CloseNotification "$nid" >/dev/null 2>&1 notify-send "recording ended - output to $outfile" } mkdir -p ~/Videos statecon=$( pidof wf-recorder ) outfile="$HOME/Videos/$(date +'%Y%m%d%H%M%S').mp4" #$outfile nid="" if [ "$statecon" == '' ]; then wf-recorder -g "$(slurp)" -f $outfile & $nid=$(notify-send -p -u critical -t 0 "recording started" --action="goto endrecplace" ) else endrec fi pidof wf-recorder && endrec