@@ -0,0 +1,2074 @@
+#!/usr/bin/python%0A%0Aimport os  # for instance management%0Afrom gi.repository import Gtk, Gdk, GObject%0A%0A# milliseconds of window getting displayed%0ADISPLAY_DURATION = 4000%0A%0A# this will get set in order to keep this obj. alive while%0ALIVING_ID = False%0A%0A# path to a temporary file for a pid.%0AMY_BAT_WARNING_PATH = %22/tmp/battery_warning_active.tmp%22%0A%0AWARNING_TEXT = %22Idiot, ur battery is dying!%22%0A%0A%0Aclass WarningDisplay(Gtk.Window):%0A%0A    def __init__(self, xdist, ydist):%0A        Gtk.Window.__init__(self, type=Gtk.WindowType.POPUP)%0A%0A        self.set_border_width(15)%0A        self.set_default_size(300, 70)%0A        self.set_decorated(False)%0A        self.move(xdist, ydist)  # distance to top left corner%0A        # little greyish%0A        self.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse(%22#222%22))%0A%0A        hbox = Gtk.Box(spacing=20)%0A        self.add(hbox)%0A        self.label = Gtk.Label(WARNING_TEXT)%0A        self.label.set_markup(%0A            '%3Cspan foreground=%22#00FFCC%22 size=%22medium%22 face=%22cursive%22%3E' + WARNING_TEXT + '%3C/span%3E')%0A%0A        hbox.pack_start(self.label, True, True, 0)%0A%0A%0Adef constructWindow():%0A    %22%22%22 construct a window and place pid file. Note the timeout ID in LIVING_ID global var.%22%22%22%0A    global LIVING_ID, DISPLAY_DURATION%0A%0A    # add self destruction after DISPLAY_DURATION milliseconds%0A    LIVING_ID = GObject.timeout_add(DISPLAY_DURATION, destroyWindow)%0A%0A    open(MY_BAT_WARNING_PATH, 'w').write(str(os.getpid()))%0A    window = WarningDisplay(50, 125)%0A%0A    window.connect(%22delete-event%22, Gtk.main_quit)%0A    window.show_all()%0A%0A    Gtk.main()%0A%0A%0Adef destroyWindow():%0A    %22%22%22 Rules for destroying the window. Remove pid file and exit gtk main loop. %22%22%22%0A    os.remove(MY_BAT_WARNING_PATH)%0A    Gtk.main_quit()%0A%0A%0Aif not os.path.exists(MY_BAT_WARNING_PATH):%0A    constructWindow()%0A%0Aelse:%0A    pid = int(open(MY_BAT_WARNING_PATH).read())%0A    try:%0A        # check if pid is running:%0A        os.kill(pid, 0)%0A    except OSError:%0A        # is not running, stale temp file found...... however:%0A        constructWindow()%0A    else:%0A        # is running! do nothing%0A        exit()%0A

Add gtk window containing some warning text, very similar to former display classes.