Don't you just love notifications? Your phone buzzing all the time. Your desktop buzzing all the time. The attention economy is the future!
Let's make the world a better place! More notifications ;)
This code will use a program called 'notify-send', which is available for Linux. For Mac or Windows you'll have to use another program.
You can send a notification to the desktop like this:
notify-send "hello" "hello" -i "face-smile"
Yes, from the terminal.
Then link the terminal command to Python functions:
#!/usr/bin/env python3 #-*- coding: utf-8 -*- import subprocess def sendmessage(message): subprocess.Popen(['notify-send', message]) return def sendmessageicon(message,icon): subprocess.Popen(['notify-send', '-i', icon, message]) return def sendmessagetitle(message,title): subprocess.Popen(['notify-send', title, message]) return def msg(message,title,icon): subprocess.Popen(['notify-send', title, '-i', icon, message]) return
It's probably better to do method overloading, but for explanation this serves its purpose. Save it as message.py
Important notifications must be sent:
Then create a new file where you load your module.
#!/usr/bin/python3 from message import sendmessage, sendmessageicon, sendmessagetitle, msg sendmessage("hello you") sendmessageicon("hello you","face-wink") sendmessagetitle("message","title") msg("message","title","face-angry")
Now our world is filled with notifications. Why not add some more useful things to that. Because of course, people have nothing better to do than the attention economy:
#!/usr/bin/python3 from message import sendmessage, sendmessageicon, sendmessagetitle, msg import time sendmessage("hello you") icons = ['face-angel','face-sad','stock_smiley-13','face-angry','face-sick','stock_smiley-15','face-cool','face-smile-big','stock_smiley-18','face-crying','face-smile','stock_smiley-1','face-devilish','face-smirk','stock_smiley-22','face-embarrassed','face-surprise','stock_smiley-2','face-glasses','face-tired','stock_smiley-3','face-kiss','face-uncertain','stock_smiley-4','face-laugh','face-wink','stock_smiley-5','face-monkey','face-worried','stock_smiley-6','face-plain','stock_smiley-10','stock_smiley-7','face-raspberry','stock_smiley-11','stock_smiley-8'] for icon in icons: sendmessageicon("Important: yada yada yada yada yada yada",icon) time.sleep(0.5)
Future versions (Android) could also buzz randomly at random time intervals. To make it perfect, it could run as daemons/services so people don't know how to turn it off.