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/
# ------------------------------------------

pid=`pgrep wf-recorder`

if [ $status != 0 ] 
  wf-recorder -f $(xdg-user-dir VIDEOS)/$(date +'recording_%Y-%m-%d-%H%M%S.mp4');
  pkill --signal SIGINT wf-recorder
# sway configuration
set $screenrecorder `bash $HOME/scripts/`
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;

Here how it looks like;