#! /bin/sh

# This is ugly but this will have to do for now, until I figure out a way to
# listen to D-Bus events to detect when the session is locked / unlocked

LOCKER="xsecurelock"

while true ; do
  XSL_PID="$(pgrep -u $(id -u) $LOCKER)"
  if [ -n "$XSL_PID" ] ; then
    printf "%s running, pausing dunst...\n" "$LOCKER"
    dunstctl set-paused true
    tail --pid $XSL_PID -f /dev/null
    printf "%s not running, unpausing dunst...\n" "$LOCKER"
    dunstctl set-paused false
  fi
  sleep 1
done
