What apps do I use most?

This is going to be my first ever ‘tech’ post on my blog, thanks to Avinash. Yesterday when we were chatting casually, he mentioned of creating an app that would track the apps that consume most of his time on the computer. It seemed a very interesting tool to have, I googled a bit and found that X on GNU/Linux platforms has a very nice querying interface through ‘xprop’ and the complete list of reference is over here: http://standards.freedesktop.org/wm-spec/wm-spec-1.3.html . So I hacked up a small script that prints active window every 10s, here it is:

while 1; do
active_wid=$(xprop -root _NET_ACTIVE_WINDOW | cut -d’#’ -f2|tr -d ‘ ‘)
active_pid=$(xprop -id $active_wid _NET_WM_PID| cut -d’=’ -f2|tr -d ‘ ‘)
active_process=$(ps -p $active_pid -o comm= )
echo $active_process
sleep 10
done;

Avinash came up with another hacked script for windows:

#include <windows.h>
#include <cstdlib>
#include <cstdio>
#include <ctime>
using namespace std;
void delay (clock_t sec);
int WINAPI WinMain (HINSTANCE hThisInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR lpszArgument,
                     int nCmdShow)
{
    while (1) {
        HWND wind = GetForegroundWindow();
        LPTSTR titlebartext;
        if (GetWindowText( wind, titlebartext, 100 ) != 0) {
            printf (“\n%s”, titlebartext);
        }
        delay (3);
    }
}
void delay (clock_t sec) {
    clock_t start_time = clock();
    clock_t end_time = sec * 1000 + start_time;
    while(clock() != end_time);
    return;
}
(PS: If you want to use it for any real world app, then kindly consider switching over from busy-wait to timer/signal based wait – http://www.kernel.org/doc/man-pages/online/pages/man2/timer_create.2.html )
I had the following output some time later:

chromium-browse
~
chromium-browse
~
chromium-browse
~
chromium-browse
~
chromium-browse
~
chromium-browse
~
chromium-browse
~
chromium-browse
~
chromium-browse
~
chromium-browse
~
chromium-browse
~
chromium-browse
~
chromium-browse
~
chromium-browse
~
chromium-browse
~
chromium-browse
~
chromium-browse
~
chromium-browse
~
chromium-browse
~
chromium-browse
~
chromium-browse
~
chromium-browse
~
chromium-browse
~
chromium-browse
~
chromium-browse
~
chromium-browse
~
gedit
~
pidgin
~
pidgin
~
pidgin
~
pidgin
~
gnome-terminal

It was my browsing time clearly ;). Until next time, happy analyzing :).

(UPDATED: 5mins after posting)

We also had an interesting conversation along line, here it is:

Avinash Krishnan: a linux person is also the kind of person who doesn’t nned to monitor his productivity quite as closely as a windows person. 😛
Adarsh: lol, true 😉
Adarsh: but I think there already exists such tools for windows
Avinash Krishnan: but, counter-irony : a windows person is also the kind of person who, when presented with performance data, i snot likely to act on it.
Avinash Krishnan: * is not likely
Avinash Krishnan: so, its useless for windows.
Avinash Krishnan: 😛
Adarsh: right 😛

Author: Adarsh

I am just another human being living on planet earth, I believe in technology and try to keep myself constantly updated with latest technologies around the corner. I am an avid computer programmer and also a sys admin who spends most of his time in configuring and keeping the services up with least errors and high availability. I am also a gadgets freak and tend to hack around with lots of interesting hardware like smart phone, wii remote, smart cards, gps receiver, usb data card etc… I am also highly interested in the field of computer and internet security and tend to do lot of experimentation with networks and lot of viruses. I am also a web programmer and designer, who loves to get the things done on the fly and go to extremes to make my app behave same on different platforms and form factors. Currently I am pursuing my Doctorate of Philosophy (PhD) in Computer Science and Engineering from Indian Institute of Technology, Kanpur. I completed my Bachelors of Engineering study at M. S. Ramaiah Institute of Technology and Masters of Technology from IITK. I had a short stint at startup with my friends at Arnium Technologies Pvt Ltd by being its CTO and forming the initial development team and infrastructure, I continue passively as a Director now. I spend my free time in mentoring students for their projects and manage some administrative work for departmental student body. I am also a FOSS enthusiast and currently manage the FOSS group, navya, here in IITK.

2 thoughts on “What apps do I use most?”

  1. Consider using the WM_NAME field from xprop output too..
    That’ll tell you /what/ you were browsing, or with /whom/ you were chatting, 😉 , with a side-effect that you might not post /that/ data quite as readily on your blog. 😛

  2. Hi,

    I created a similar application sometime ago.
    I made it in java, and added some analytics feature to it.
    It sums up the total time spend on a particular application for the entire week and gives pie charts.

    Checkout https://sourceforge.net/projects/jitendriya/

    Right now this “window name finding” part works only on windows.
    Trying to get it to work on linux.

    Thanks
    Cheers

Leave a Reply

Your email address will not be published. Required fields are marked *

*