<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Code Ripper</title>
    <description>The latest articles on DEV Community by Code Ripper (@coderipper).</description>
    <link>https://dev.to/coderipper</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F164597%2F6b4ac2b7-e722-4e93-8443-a0b3d05414f3.jpeg</url>
      <title>DEV Community: Code Ripper</title>
      <link>https://dev.to/coderipper</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/coderipper"/>
    <language>en</language>
    <item>
      <title>Sense of time.py</title>
      <dc:creator>Code Ripper</dc:creator>
      <pubDate>Sat, 11 Sep 2021 16:51:06 +0000</pubDate>
      <link>https://dev.to/coderipper/sense-of-time-py-1i0f</link>
      <guid>https://dev.to/coderipper/sense-of-time-py-1i0f</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;The trouble is, you think you have time. - Jack Kornfield&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is my first blog, thought of starting with a quote :-).&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;Research studies have proven that &lt;strong&gt;A regular reminder of passage of time seems to have a definite good impact on one's efficiency and productivity&lt;/strong&gt;&lt;em&gt;(don't look it up!)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So I have decided to create a very simple background process that reminds you the time every quarter-hour.&lt;/p&gt;

&lt;p&gt;We are going to use python and crontab service in your MacOS.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/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") + '"')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Simple, indeed&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;As you can see, we have used say-command, which is a CLI for &lt;a href="https://developer.apple.com/documentation/applicationservices/speech_synthesis_manager"&gt;Speech Synthesis Manager&lt;/a&gt;. &lt;em&gt;I didn't like the default high-pitched male voice, so I changed to &lt;code&gt;-v Samantha&lt;/code&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Put the above python snippet in a file, save it somewhere and copy the file path. In my case, it is &lt;code&gt;~/dev/scripts/sense_of_time.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now, we are gonna use &lt;a href="https://ole.michelsen.dk/blog/schedule-jobs-with-crontab-on-mac-osx/"&gt;crontab&lt;/a&gt; - &lt;em&gt;explained by one of my favourite blogger Ole Michelsen&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Open your terminal and run &lt;code&gt;crontab -e&lt;/code&gt; to edit the job list. it will be empty, if you don't have any job configured.&lt;/p&gt;

&lt;p&gt;We are gonna configure a new job now. Paste the below line in crontab job file,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; */15 * * * * /usr/local/bin/python3 ~/dev/scripts/sense_of_time.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Explanation:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;*/15 * * * *&lt;/code&gt; - cron expression tells when the job should run. Change this expression if you want it to run at different time interval.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/usr/local/bin/python3&lt;/code&gt; - path of python binary, &lt;em&gt;change it if your path is different&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;~/dev/scripts/sense_of_time.py&lt;/code&gt; - path of your python file.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now, save and close the file to install the cronjob, if you are using vim, press ESC, type &lt;code&gt;:wq&lt;/code&gt; and hit enter.&lt;/p&gt;

&lt;p&gt;you should see&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ crontab -e
crontab: installing new crontab
$
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it!&lt;/p&gt;

&lt;p&gt;When the time is *:15/30/45/00, you will get a voice reminder.&lt;/p&gt;

&lt;p&gt;How cool is that!&lt;/p&gt;

&lt;p&gt;See ya!&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>python</category>
    </item>
  </channel>
</rss>
