GitMonitor.js
[gitlive] / WindowLog.js
index 499385c..acd0d49 100644 (file)
@@ -24,7 +24,7 @@ const Gio = imports.gi.Gio;
 
 //Gtk.init(Seed.argv);
 const xDate = imports.Date;
-const xorg = imports.xorg;
+const xorg = typeof(Seed) != 'undefined' ? imports.xorg : false;
 
 WindowLog = {
     
@@ -36,17 +36,26 @@ WindowLog = {
         
         this.outdir = GLib.get_home_dir() + "/.gitlog";
         this.screen = Wnck.Screen.get_default();
-        GLib.timeout_add(GLib.PRIORITY_LOW, 500, function() { return WindowLog.getStatus() } );
-        
+        // 
+        GLib.timeout_add(GLib.PRIORITY_LOW, 5000, function() {
+            return WindowLog.getStatus()
+        } );
+        //Roo.log("Windowlog start");
+        this.screen.signal.active_window_changed.connect(function() {
+            WindowLog.windowChanged();
+        });
     },
-        
+    
+    
+    
+    
     getStatus : function()
     {
         
          
         var output =  xorg.screensaverinfo_get_idletime();
         //print(output);
-         
+        // more that 10 seconds?? - report idle..
         if (output * 1 > 10000) {
             if (this.win != false) { 
                 print( (xDate.newDate()).format("Y-m-d H:i:s") + " IDLE");
@@ -55,9 +64,12 @@ WindowLog = {
             this.win = false;
             return true;
         }
-        
+        return true;
+    },
+     windowChanged : function()
+    {
         this.screen.force_update();
-       
+       // print("window changeD");
         var aw = this.screen.get_active_window();
         if (aw) { 
             var win = aw.get_name();