I use this to fire off a cryptominer when my screen locks. Works on Fedora 26
I run this command as a batch file in screen. Could be made into a daemon i suppose but screen works good enough for now
dbus-monitor --session "type=signal,interface=org.gnome.ScreenSaver" |
while read MSG; do
LOCK_STAT=`echo $MSG | grep boolean | awk '{print $2}'`
if [[ "$LOCK_STAT" == "true" ]]; then
echo "was locked"
killall myfile
screen -d -m /pathto/myfile -flags
else
echo "was un-locked"
killall
myfile
fi
done