2013-09-13

Waste less time (OS/X)


There is a very interesting application called WasteNoTime that is available for Safari and Chrome. This app allows you to create a schedule during which time limited or no access is allowed to certain web sites. I've found this to be a very valuable tool.
However, there are other web browsers around, and sometimes, even though it's time to get to work, the temptation to make just one more comment or to finish reading a very interesting article is too strong, and I end up firing up OmniWeb or Opera (which do not support WasteNoTime) in order to waste just a little more time. But this is pernicious, because “just a little more” can soon become hours. Oh ye of little will power.
Well, it would be great to have some kind of impediment that would at least make it less convenient to use those browsers (or certain other applications) during work hours.
So, here's how I decided to do it.
There is a command called “chmod” that can change permissions on files or folders. If certain permissions are not set on an application (e.g., /Applications/Opera.app), it cannot be executed. So my very simple idea is based on this script:

#!/bin/ksh
# Usage: lockBrowsers.ksh lock|unlock
# very simple locker for all web browsers that do not have any means of
# restricting time-wasting activities; to be called by cron. (Note that both
# Safari and Chrome have the WasteNoTime app, which is better than this.) We do
# allow some time wasting a couple of days per week (but not on weekends).

# Current schedule:

# Unlocked every day at 7PM
# Locked every day at 10PM
# Unlocked M F at 6AM

APP=/Applications

set -A Waster FireFox OmniWeb Opera

case "$1" in

lock ) m="a-x" ;;
unlock ) m="a+x" ;;
ls ) m=ls ;;
* ) print -u2 "Usage: $(basename $0) lock|unlock|ls" ; exit 1 ;;
esac

for (( i=0 ; i<${#Waster[*]} ; i++ )) ; do

if [[ $m == ls ]] ; then
ls -ld $APP/${Waster[i]}.app
else
chmod $m $APP/${Waster[i]}.app
fi
done

exit 0


This very simple script contains a list of applications, and if called with an argument “lock”, locks them by removing execute/search permission at the top level; if called with an argument “unlock”, unlocks them by restoring execute/search permission. NOTE: you must own the applications you want to use this with. For example, Safari and other system commands might be owned by root, and in that case, this method will fail.
I installed the script, called “lockBroswers.ksh” in the libexec folder in my home directory.
Next, using the command “crontab -e”, I set up the schedule I wanted:

0 19 * * * ~/libexec/lockBrowsers.ksh unlock
0 22 * * * ~/libexec/lockBrowsers.ksh lock

This lets me use those applications in the evening every day. You can read the crontab documentation if you want some other schedule, as you probably will.

No comments:

About Me

My photo
Ignavis semper feriƦ sunt.