notification if disk is (almost) full

Notify when running  out  of diskspace

I wanted to have a nice little application that would notify me when I'm running low on resources and my diskspace is getting less then 100Mb.

so I made this little Python script that runs in the background and shows a popup whenever my disk is getting full again.

#!/usr/bin/env python
try:
    import gtk, pygtk, os, os.path, pynotify
    pygtk.require('2.0')
except:
    print "Error: need python-notify, python-gtk2 and gtk"
import time


def freespace(p):
   s = os.statvfs(p)
   a = (s.f_bsize * s.f_bavail) / 1048576
   return a

while True:
while freespace("/") < 100:
      freespace_ =  str(freespace("/"))
      pynotify.init('test')
      msg = pynotify.Notification("Running out of resources \nCurrently available diskspace", freespace_+"MB" )
      msg.show()
      time.sleep(60)
time.sleep(60)