1 //<script type="text/javascript">
3 * log desktop actions..
5 * a potential add-on to gitlive....
6 * - basically tracks what applications are being worked on when, allowing you to
7 * use it to generate time tracking (eg. invoices...) later..
10 * xdotool getmouselocation
12 * xwit -property WM_NAME -print
13 * 0x3a13d6c: x=1 y=25 w=1109 h=747 d=32 'root@wideboy: /home/alan'
14 * root@wideboy:/home/alan# xwit -property WM_CLASS -print
15 * 0x3a13d6c: x=1 y=25 w=1109 h=747 d=32 'gnome-terminal'
16 * root@wideboy:/home/alan#
19 * Not sure how we handle last key press...
21 * -- log to a remote url.
24 * DATE / TIME / Application / Title
25 * if cursor same as before.. - SEND 'IDLE'... (twice, then stop sending..)
27 * For commits... (we send out every 1 minute as well, it's upto the other end to determine if that means updating
28 * or creating a new record..
29 * yyyy-mm-dd /12:00 / GIT / XXXXX
32 * apt-get install gir1.2-wnck-3.0
40 Wnck = imports.gi.Wnck;
41 Gtk = imports.gi.Gtk ;
42 Spawn = imports.Spawn;
43 File = imports.File.File;
44 GLib = imports.gi.GLib;
45 //Gtk.init(Seed.argv);
55 this.outdir = GLib.get_home_dir() + "/.gitlog";
56 this.screen = Wnck.Screen.get_default();
57 GLib.timeout_add(GLib.PRIORITY_LOW, 500, function() { return WindowLog.getStatus() } );
61 getStatus : function() {
63 var output = Spawn.run({
64 cwd : __script_path__ + '/tests',
65 args : [ __script_path__ + '/tests/xidletime' ]
69 if (output * 1 > 10000) {
70 if (this.win != false) {
71 print( (xDate.newDate()).format("Y-m-d H:i:s") + " IDLE");
77 this.screen.force_update();
78 var aw = this.screen.get_active_window();
80 var win = aw.get_name();
81 if (!this.win || (this.win && win != this.win)) {
83 print((xDate.newDate()).format("Y-m-d H:i:s") + " " + win);
94 write : function (str) {
96 var dir = this.outdir + (xDate.newDate()).format("/Y/m");
97 if (!this.lastdir || this.lastdir != dir) {
98 if (!File.isDirectory(dir)) {
104 var path = dir + (xDate.newDate()).format("/d") + ".log";
105 var time = (xDate.newDate()).format("H:i:s ")
107 File.append (path, time + str + "\n");