Implementation for Linux:
#!/bin/bash
set -e
while true; do
sleep 20m
xlock -allowaccess&
pid=$!
sleep 20s
kill $pid
done
Check the manpage for xlock and choose a screensaver that won't keep you looking at the monitor.