I spent some time creating a tool to block sites and apps based on schedules as well as to track behaviour. This is an overview of how it works.
The application is completely open source and available at the official site
Blocking
Blocking is done by putting domains into /etc/hosts, pointed at localhost, and the file is made immutable with chattr +i. A small server on 127.0.0.1 answers those requests with a blocked page and logs the hit. The domains are fetched from public blocklists. Domains which have web based proxies are also blocked. A Firefox/Chrome extension, force-installed through the browsers' enterprise policies, catches keywords in URLs and page content. Programs on a list are killed during their windows. Repeated violations run a command of your choice, usually a screen lock you can't dismiss until it times out.
Taking away sudo
If glocker is uninstalled, all protections are lifted.…