| import wnck␊ |
| ␊ |
| ␊ |
| do_debug = False␊ |
| do_debug = True␊ |
| icon_running = '/home/loa/Projects/Activity/src/icons/activity-running.png'␊ |
| icon_stopped = '/home/loa/Projects/Activity/src/icons/activity-stopped.png'␊ |
| timeout_answer = 30␊ |
| fullscreen = True␊ |
| ␊ |
| PIDFILE = '/home/loa/.gnome2/activity.pid'␊ |
| ␊ |
| from datetime import date, timedelta␊ |
| ␊ |
|
| self.interval = 5*60*1000␊ |
| ␊ |
| self.init_status_icon()␊ |
| ␊ |
| signal.signal(signal.SIGHUP, self.signal_handler)␊ |
| ␊ |
| def signal_handler(self, sig, stack):␊ |
| """Handle the signal sent to the daemon."""␊ |
| if sig == signal.SIGHUP:␊ |
| debug("signal.SIGHUP: Stop the current activity")␊ |
| self.stop()␊ |
| ␊ |
| def _makeAskWindow(self, task, lasttime):␊ |
| """Construct the prompt window. Returns (window, textentry␊ |
| widget, countdown widget)␊ |
|
| interval = 5*60*1000␊ |
| gui = ActivityGUI(ActivityMonitor())␊ |
| gui.interval = interval␊ |
| # Set the pid file␊ |
| pid = os.getpid()␊ |
| open(PIDFILE,'w').write("%d"%pid)␊ |
| if waitbefore:␊ |
| import time␊ |
| time.sleep(30)␊ |
|
| except KeyboardInterrupt:␊ |
| debug("KeyboardInterrupt: Stop the time")␊ |
| gui.activityMonitor.stop()␊ |
| try:␊ |
| os.remove(PIDFILE)␊ |
| except Exception, e:␊ |
| pass␊ |
| return 0␊ |
| ␊ |
| if __name__ == '__main__':␊ |
| main()␊ |