Today, I whipped together a simple, effective parental control script for our shared Macbook Air. For many months, our homeschooled son has been easily distracted by videos and messages when he is supposed to be working hard on crafting a good paragraph. Apples parental controls are a massive #FAIL – deselecting the default apps do not work and you cannot just simply turn off the Internet.
All the script does is turn off the Internet. The “garrett” account, limited to 30 minutes, has Internet access. There is a shared account for homeschool work, which this script ensures has no Internet access.
#!/bin/bash counter=0 while true do if last | grep garrett | grep "still logged in" then echo "garrett logged in, do not kill internet" else echo "garrett NOT logged in, kill internet" networksetup -setairportpower en0 off fi counter=$((counter+1)) echo $((counter)). sleeping 10 seconds $(date) sleep 10 done
That’s it. Just turn off Internet access on a single computer.