Running a command when screen locks
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
1dbus-monitor --session "type=signal,interface=org.gnome.ScreenSaver" |
2 while read MSG; do
3 LOCK_STAT=`echo $MSG | grep boolean | awk '{print $2}'`
4 if [[ "$LOCK_STAT" == "true" ]]; then
5 echo "was locked"
6 killall myfile
7 screen -d -m /pathto/myfile -flags
8 else
9 echo "was un-locked"
10 killall myfile
11 fi
12 done