Desktop Notifications with Python
Tags: python, satire, jokes
Published: 2019-07-06 11:43:19

---
title: Desktop Notifications with Python
published: true
description: python, notifications 
tags: python, satire, jokes
cover_image: https://thepracticaldev.s3.amazonaws.com/i/in9exvfcn9stmwa7pigd.png
---
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.

### Notifications

You can send a notification to the desktop like this:

    notify-send "hello" "hello" -i "face-smile"

Yes, from the terminal.

![](https://thepracticaldev.s3.amazonaws.com/i/u0l4c3p7sr44e6muso1w.png)

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:

<img src="https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F1229mlttgo8aR2%2Fgiphy.gif&f=1">


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")

**Pay Attention:**

<img src="https://proxy.duckduckgo.com/iu/?u=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FxTiTnhMOQ4zE0ukz2U%2Fgiphy.gif&f=1">

### Current situation: Attention Economy

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.  

Ahhh... perfection:

![](https://thepracticaldev.s3.amazonaws.com/i/cq2sj65g6i4vt32mbbiv.png)

Read More:

* https://humanetech.com/
* https://techcrunch.com/2017/07/30/the-attention-economy-created-by-silicon-valley-is-bankrupting-us/
* https://pythonbasics.org
* https://pythonprogramminglanguage.com