I was writing an runit service to restart picom on unlock based on this answer https://unix.stackexchange.com/a/439492/161514
#!/bin/bash
OBJECT_PATH=/org/freedesktop/login1/session/$XDG_SESSION_ID
BUS_NAME=org.freedesktop.login1
UNLOCK="$OBJECT_PATH: $BUS_NAME.Session.Unlock ()"
MONITOR_COMMAND="gdbus monitor --system --dest $BUS_NAME --object-path $OBJECT_PATH"
log () {
echo "$(date +'%F %T.%3N') [$$]" "$@"
}
while read -r signal; do
log $signal
if [ "$signal" = "$UNLOCK" ]; then
log "Restaring picom after unlock."
SVDIR=$XDG_SERVICE_HOME sv restart picom
fi
done < <(exec $MONITOR_COMMAND)
The issue with this is that when I stop the service the gdbus process won't get killed. I can guess that it's because there will be two processes the script itself and then the gdbus and the service stop will only stop the script not gdbus.
My question is can I rewrite this service in some way to achieve what I want so that stopping the service the gdbus monitoring also stops?