You are not logged in.
Hi guys,
I have been googling and could not find anything that would help me to measure how much time do I waste when sitting in front of computer.
I would like to measure time of active windows (so i.e. if I'm doing coding and kwrite is opened and active I would like to know how much time I have spent on it, and if in the meantime I do firefox to check facebook I want that logged)
I found this: https://www.archlinux.org/packages/comm … e-tracker/
- the problem with that is that (as far as I understand) it is not fully background thing, I have to switch tasks myself - and I would like such program to do all the measurements behind the scenes.
I also found this comparison: http://alternativeto.net/software/time- … form=linux
- most of the stuff listed there is 'freemium' which won't show up in our repos
Do you guys know a software package I would use to measure time spent on active window?
Offline
Not System Admin, moving to "Applications & Desktop Environments"
Are you familiar with our Forum Rules, and How To Ask Questions The Smart Way?
BlueHackers // fscanary // resticctl
Offline
I don't know much about the programs you refer to - but unless you need some fancy interface, there isn't much needed for this. The following code will track any focus changes and output tab separated values of a unix time stamp and the title of the (newly) focused window. If you pipe this to a file, you can pull it into your favorite spreadsheet or data analysis software and do whatever calculations or summary statistics you'd like.
#include <stdio.h>
#include <time.h>
#include <X11/Xlib.h>
int main() {
Display *dpy = XOpenDisplay(0x0);
XSelectInput(dpy, DefaultRootWindow(dpy), FocusChangeMask);
Window win;
int ignore;
char *title;
XEvent ev;
while (!XNextEvent(dpy,&ev)) {
XGetInputFocus(dpy, &win, &ignore);
if (XFetchName(dpy, win, &title)) {
printf("%d\t%s\n", time(NULL), title);
XFree(title);
}
}
return 0;
}
(compile with `gcc -o track track.c -lX11`)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Thanks Trilby,
Would I then run this program only once on startup or somehow bind it to KDE?
Offline
That's up to you - it has to be started after X. If I were to use it, I'd put it in my xinitrc:
track > ~/track.log &
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
I see - the program runs in infinite loop waiting for events. So when added to xinitrc it will simply run after X. I assume when system will shut down the program will just receive kill (therefore system won't hung waiting for the program to terminate),
Need to test this, thanks Trillby!
Offline