In this story we shall see a python based app which gives voice and notification reminders to take a break for relaxing, drink water and greet the user based on time.
We see that when we are involved in some work or other we loose track of time and forget to even have the food for both mind and body. Unless someone reminds us to have food or water we forget and neglect to drink water.
Okay coming to the point, we are going to see a simple python based app to remind us to drink water and take break from our routine for every 35 minutes. Idea is very simple, we use the schedule package available for python and define methods to be called as and when required. The packages required to be installed are notify2, Schedule, espeak.
The commands for installing the required package are given as following:
To install the required packages use :
1. Notify2 pip3 install notify2
2. Schedule pip3 install schedule
3. Espeak sudo apt-get install espeak
Let me explain the code embedded below, firstly we import the required modules for our program. We import notify2 package to notify users through a bubble notification, getpass to get the user details, os to execute the espeak commands, schedule to run required methods at required time and the time module.
We have defined three methods for our simple program, firstly we have defined method related to reminder related to drink water. In the code we can see that based on the user name the message is generated and is executed as a voice command and a notification. Similarly we also have the third method related to taking break. We use the schedule package for scheduling the method take_a_break to be executed every 35 minutes which in fact reminds us about take a break. Lastly we also have a wish method which wishes the user every 8 hours based on the current time and is first executed in our program. This method takes the local time and gets the time in 24 hour format and accordingly prepares the message for the greetings. We can also see that in the code, the main has a while loop which actually does the scheduled pending jobs run.
More information refer following links :
This is a simple python based app suitable for ubuntu. Many other additional features and other methods can be incorporated as required and this can be integrated with other modules and a simple jarvis, kind of personal assistant can be made. This project is on the way and will be updated soon.