How to play an alarm/sound notification in your (python) application

On the other day, I decided to add a sound notification to my unity pomodoro applet and I did a little research. Turns out there are a few options to do this, but not many examples on the internet. And some of those options depend heavily on the operating system and the installation of external modules.

So I ended up being grateful, again, for the invention of Stack Overflow! :)

My solution:

from os import popen

popen("canberra-gtk-play --file=" +
      os.path.join(os.path.dirname(os.path.realpath(__file__)), 'sounds/sound.ogg') + 
      " > /dev/null 2>&1 || true")

Continue reading