The trouble is, you think you have time. - Jack Kornfield
This is my first blog, thought of starting with a quote :-).
With work from home being a new normal, we often get distracted by something and lost the track of time. Might Not be everyone, but people like me.
Research studies have proven that A regular reminder of passage of time seems to have a definite good impact on one's efficiency and productivity(don't look it up!)
So I have decided to create a very simple background process that reminds you the time every quarter-hour.
We are going to use python and crontab service in your MacOS.
#!/usr/bin/env python
import os
import time
# Say current time
os.system('say -v Samantha "The time is now ' + time.strftime("%I:%M %p") + '"')
Simple, indeed
As you can see, we have used say-command, which is a CLI for Speech Synthesis Manager. I didn't like the default high-pitched male voice, so I changed to -v Samantha
Put the above python snippet in a file, save it somewhere and copy the file path. In my case, it is ~/dev/scripts/sense_of_time.py
Now, we are gonna use crontab - explained by one of my favourite blogger Ole Michelsen
Open your terminal and run crontab -e
to edit the job list. it will be empty, if you don't have any job configured.
We are gonna configure a new job now. Paste the below line in crontab job file,
*/15 * * * * /usr/local/bin/python3 ~/dev/scripts/sense_of_time.py
Explanation:
-
*/15 * * * *
- cron expression tells when the job should run. Change this expression if you want it to run at different time interval. -
/usr/local/bin/python3
- path of python binary, change it if your path is different -
~/dev/scripts/sense_of_time.py
- path of your python file.
Now, save and close the file to install the cronjob, if you are using vim, press ESC, type :wq
and hit enter.
you should see
$ crontab -e
crontab: installing new crontab
$
That's it!
When the time is *:15/30/45/00, you will get a voice reminder.
How cool is that!
See ya!
Top comments (0)