wf-recorder indicator for waybar

Hey all! You know that I shared my latest setup in the previous blog post and if you noticed that there is a shortcut in the sway configurations to start/stop screen recording with wf-recorder . Yesterday, I just realized that I accidentally hit the shortcut and started a recording on background and my computer was about the cry after probably a couple of hours. So I decided to create an indicator for the waybar to show ongoing screen recording.

You can also get the configs from here

# $HOME/scripts/toggle-screen-recording.sh
# ------------------------------------------

#!/bin/bash 
pid=`pgrep wf-recorder`
status=$?

if [ $status != 0 ] 
then 
  wf-recorder -f $(xdg-user-dir VIDEOS)/$(date +'recording_%Y-%m-%d-%H%M%S.mp4');
else 
  pkill --signal SIGINT wf-recorder
fi;
# sway configuration
set $screenrecorder `bash $HOME/scripts/toggle-screen-recorder.sh`
bindsym --to-code $mod+Shift+R exec $screenrecorder
// Custom waybar module 
"custom/recorder": {
  "format": "",
  "return-type": "json",
  "interval": 1,
  "exec": "echo '{\"class\": \"recording\"}'",
  "exec-if": "pgrep wf-recorder"
}
/* styles for recorder */
#custom-recorder {
	font-size: 18px;
	margin: 2px 7px 0px 7px;
	color:#c9545d;
}

Here how it looks like;

Result