* FIXME - needs perms setting..
*
* @arg directory {String} Directory to make
+ * @arg recursive {Boolean}
*/
- mkdir : function (destPath) {
+ mkdir : function (destPath, rec) {
+ //print("mkdir: " + destPath);
+ rec = rec || false;
+ if (rec && !File.isDirectory(GLib.path_get_dirname(destPath))) {
+ File.mkdir(GLib.path_get_dirname(destPath),true);
+ }
+
var dest = Gio.file_new_for_path(String(destPath));
return dest.make_directory(null);
},
* For commits... (we send out every 1 minute as well, it's upto the other end to determine if that means updating
* or creating a new record..
* yyyy-mm-dd /12:00 / GIT / XXXXX
+ *
+ *
+ * apt-get install gir1.2-wnck-3.0
+ *
*
*/
+
+Wnck = imports.gi.Wnck;
+Gtk = imports.gi.Gtk ;
+Spawn = imports.Spawn;
+File = imports.File.File;
+GLib = imports.gi.GLib;
+//Gtk.init(Seed.argv);
+xDate = imports.Date;
+
+WindowLog = {
+
+ win : false,
+ screen : false,
+
+ start : function()
+ {
+ this.outdir = GLib.get_home_dir() + "/.gitlog";
+ this.screen = Wnck.Screen.get_default();
+ GLib.timeout_add(GLib.PRIORITY_LOW, 500, function() { return WindowLog.getStatus() } );
+
+ },
+
+ getStatus : function() {
+
+ var output = Spawn.run({
+ cwd : __script_path__ + '/tests',
+ args : [ __script_path__ + '/tests/xidletime' ]
+ });
+ //print(output);
+
+ if (output * 1 > 10000) {
+ if (this.win != false) {
+ print( (xDate.newDate()).format("Y-m-d H:i:s") + " IDLE");
+ this.write("IDLE");
+ }
+ this.win = false;
+ return true;
+ }
+ this.screen.force_update();
+ var aw = this.screen.get_active_window();
+ if (aw) {
+ var win = aw.get_name();
+ if (!this.win || (this.win && win != this.win)) {
+
+ print((xDate.newDate()).format("Y-m-d H:i:s") + " " + win);
+ this.write(win);
+ this.win=win;
+ }
+ }
+
+
+ return true;
+ },
+ lastdir : false,
+
+ write : function (str) {
+
+ var dir = this.outdir + (xDate.newDate()).format("/Y/m");
+ if (!this.lastdir || this.lastdir != dir) {
+ if (!File.isDirectory(dir)) {
+ File.mkdir(dir,true);
+ }
+ this.lastdir = dir;
+ }
+
+ var path = dir + (xDate.newDate()).format("/d") + ".log";
+ var time = (xDate.newDate()).format("H:i:s ")
+
+ File.append (path, time + str + "\n");
+ }
+
+}
+
+
+
\ No newline at end of file