I have a Python script with the following code:
import subprocess
import sys
default = "Take a 20 second break - look at least 20 feet away!"
message = sys.argv[1] if len(sys.argv) > 1 else default
def sendmessage(message):
subprocess.Popen(['notify-send', message])
return
sendmessage(message)
called takebreak.py
, which will send a system notification.
When I try to automate it using crontab
like so:
* * * * * /usr/bin/python /home/polo/git-repositories/takebreak/takebreak.py
It doesn't work. Running the command
/usr/bin/python /home/polo/git-repositories/takebreak/takebreak.py
in the terminal does work, which means it's not a file location problem, but rather something to do with cron
. Any ideas?
EDIT1:
After debugging and looking at the logs, I can verify that cron is actually executing the commmand export DISPLAY=:0; /usr/bin/python /home/polo/git-repositories/takebreak/takebreak.py
every minute like I set it to do, but for some reason this command, while it should send a system notification, is not doing so.
Any ideas?
EDIT2:
The solution was to add some address bus thing (forget the exact code) that I found in another post, that ended up fixing it. Unfortunately, none of the answers or comments here helped with solving the problem, but thanks regardless!