Originally published at
Dom's Blog. You can comment here or
there.
Inspired by pages such as
this one and
this one, I decided to implement this as a one-liner which I can execute as a script:
while true ; do l2ping -c 4 00:12:D2:BA:B3:12 || gnome-screensaver-command -l ; sleep 10 ; done
Clearly it’s not a daemon, and it probably drains the battery of my phone by pinging it every ten seconds, but it works if I walk to the other end of the apartment. I guess it needs a bit of work, such as implementing my phone’s MAC address as a variable or stored in a file, but it’s nice and simple and demonstrates how it works quite nicely without all the surrounding script.