diff options
| author | Daniel Baumann <daniel@debian.org> | 2007-09-23 14:46:22 +0200 |
|---|---|---|
| committer | Daniel Baumann <daniel@debian.org> | 2007-09-23 14:46:22 +0200 |
| commit | 4a0b1ba4d428c623d14bae7f0db85c80abb0da0a (patch) | |
| tree | de03aceffba0ce13f098d970cc89f806db7af5d7 /caspermon | |
| download | live-boot-4a0b1ba4d428c623d14bae7f0db85c80abb0da0a.tar.gz live-boot-4a0b1ba4d428c623d14bae7f0db85c80abb0da0a.zip | |
Adding casper 1.59+debian-1.
Diffstat (limited to 'caspermon')
| -rw-r--r-- | caspermon/GNOME_PythonAppletCasper.server | 30 | ||||
| -rwxr-xr-x | caspermon/caspermon-applet | 75 | ||||
| -rw-r--r-- | caspermon/caspermond | 9 |
3 files changed, 114 insertions, 0 deletions
diff --git a/caspermon/GNOME_PythonAppletCasper.server b/caspermon/GNOME_PythonAppletCasper.server new file mode 100644 index 0000000..34caa04 --- /dev/null +++ b/caspermon/GNOME_PythonAppletCasper.server @@ -0,0 +1,30 @@ +<oaf_info> + +<oaf_server iid="OAFIID:GNOME_PythonAppletCasper_Factory" + type="exe" + location="/usr/share/casper-applet/casper-applet.py"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:Bonobo/GenericFactory:1.0"/> + <item value="IDL:Bonobo/Unknown:1.0"/> + </oaf_attribute> + <oaf_attribute name="name" type="string" value="PythonAppletCasper"/> + <oaf_attribute name="description" type="string" value="Python Applet CAsper"/> +</oaf_server> + +<oaf_server iid="OAFIID:GNOME_PythonAppletCasper" + type="factory" + location="OAFIID:GNOME_PythonAppletCasper_Factory"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:GNOME/Vertigo/PanelAppletShell:1.0"/> + <item value="IDL:Bonobo/Control:1.0"/> + <item value="IDL:Bonobo/Unknown:1.0"/> + </oaf_attribute> + <oaf_attribute name="name" type="string" value="PythonAppletCasper"/> + <oaf_attribute name="description" type="string" value="Python Applet Casper"/> + <oaf_attribute name="panel:category" type="string" value="Utility"/> + <oaf_attribute name="panel:icon" type="string" value="bug-buddy.png"/> +</oaf_server> + +</oaf_info> diff --git a/caspermon/caspermon-applet b/caspermon/caspermon-applet new file mode 100755 index 0000000..773e0a4 --- /dev/null +++ b/caspermon/caspermon-applet @@ -0,0 +1,75 @@ +#!/usr/bin/python + +import pygtk +pygtk.require('2.0') + +import gtk +import gnome.applet +import subprocess +import os + +# A simple applet to display the utilization of the snapshot device +# during a casper session +# +# Matt Zimmerman <mdz@canonical.com> + +# TODO: +# - tooltip with details +# - flash at threshold + +class CasperApplet: + def __init__(self, applet, iid): + self.timeout_interval = 1000 + self.device = 'casper-snapshot' + self.capacity = [0,0] + self.datafile = '/var/lib/casper/snapshot-status' + + # initializate the gnome internals + gnome.init("casper", "0.1") + + self.applet = applet + + self.tooltips = gtk.Tooltips() + self.hbox = gtk.HBox() + applet.add(self.hbox) + + # add the second button event for the popup menu and the enter mouse event to change the tooltip value + self.ev_box = gtk.EventBox() + #self.ev_box.connect("button-press-event",self.button_press) + self.ev_box.connect("enter-notify-event", self.update_info) + self.hbox.add(self.ev_box) + + self.prog = gtk.ProgressBar() + self.ev_box.add(self.prog) + + self.update_info() + + gtk.timeout_add(self.timeout_interval,self.update_info, self) + + applet.connect("destroy",self.cleanup) + applet.show_all() + + def update_info(self, event=None): + self.capacity = self.read_info() + self.prog.set_fraction(float(self.capacity[0]) / self.capacity[1]) + self.prog.update() + + def read_info(self): + fields = open(self.datafile).readline().split() + if fields[2] != 'snapshot': + return None + + return map(int,fields[3].split('/', 1)) + + def cleanup(self): + # what goes here? + pass + +def casper_factory(applet, iid): + CasperApplet(applet, iid) + + return gtk.TRUE + +gnome.applet.bonobo_factory("OAFIID:GNOME_PythonAppletCasper_Factory", + gnome.applet.Applet.__gtype__, + "casper", "0", casper_factory) diff --git a/caspermon/caspermond b/caspermon/caspermond new file mode 100644 index 0000000..e126447 --- /dev/null +++ b/caspermon/caspermond @@ -0,0 +1,9 @@ +#!/bin/sh + +STATEFILE=/var/run/caspermond/status.casper-snapshot + +while true; do + dmsetup status /dev/mapper/casper-snapshot > $STATEFILE.new + mv $STATEFILE.new $STATEFILE + sleep 60 +done |
