One day build – Scheduler

If have to do anything more than twice, I’m likely to make a script to help. 

Like so many others we are keeping to ourselves these days and it was helpful to make a scheduler pop-up for telling me when to move my child onto the next task during the day. Enter my super easy one day build. 

The relevant library was notify2 in python.  It tells my OS to pop-up a notification and send me a message.

import notify2
from playsound import playsound as ps
import schedule
import time

Then I set the important variables and initialize the relevant objects. These are a Notification object and a sound file name string. 

notify2.init("MyName")
n = notify2.Notification(None)
n.set_urgency(notify2.URGENCY_CRITICAL)
n.set_timeout(5000)
song_file = "gw151226.mp3" 

It plays a gravitational wave chirp. Quite nice. Then, I define one of several ‘jobs’.

def job1():
    n.update("message!")
    n.show()
    ps(song_file)

where ps is playsound.playsound() from the import line. It is then invoked with some variant of the ‘schedule’ program. 

schedule.every().day.at("08:30").do(job1)

And that’s all there is. 

Be well, stay safe, wear a mask. 

N

 

Author: Calcumore

Physicist, Programmer, Calcumore and calcunow.

Leave a Reply

Your email address will not be published. Required fields are marked *