1

I am very much concerned about my productivity all the time. I have recently come across this beautiful chrome extension Limitless

But this is only measuring what i'm doing within the chrome application. As I work most of the time with pdfs, videos etc, I want to develop similar application for linux(ubuntu) desktop enviroment.

Basically I want the script to run continuously as long as the workstation is on. It should be able to know what I'm currently looking at (for eg a pdf file or a lecture video in vlc) and get the name of the respective file, start time, end times etc and finally post to db. It is better if it could know if the system is idle or at sleep.

I don't have slightest clue at bash scripting. so my questions is could this task be accomplished with python.

What I've tried?
I started with a search in google "get current application python", "current window title python" etc etc and really surprised to see absurd results.

Please give me pointers on this.

Krishna Deepak
  • 1,735
  • 2
  • 20
  • 31

2 Answers2

2

I think you are asking for vocabulary. So I give you what I know.

You are using Ubuntu so your Window Manager may be Gnome. The window manager knows which window has the focus. So maybe you want to find out which window has the focus and you want to map it to the Process that opened the window. What you need to focus on is is module for Python or a Python Binding for the window manager. This module is likely to also be able to control the windows.

The window manager is started with startx.

User
  • 14,131
  • 2
  • 40
  • 59
  • Note that often you're actually "working on" things that don't have focus (e.g., right now, even though Chrome has focus, I've got an emacs window that I'm scrolling through with the trackpad, and doing more reading there than here), and there's no general purpose way to know which file a process is displaying in a window (sometimes there _is_ no answer to that). But those are problems with the question, not with the answer; this explains how to do almost everything that conceivably _could_ be done for the OP's question. – abarnert Jan 17 '14 at 23:38
0

You could try to call a command line tool and catch the results

How do get the process list on command line: https://stackoverflow.com/questions/53489/how-do-you-list-all-processes-on-the-command-line-in-windows

And how to call a tool with python: Python subprocess.call and subprocess.Popen stdout

[edit] Repeating the call in Intervals and counting the intervals a process were running gives you a good estimation of running time of a process...

[edit2] As GreenAsJade said, you search a way to find out which windows has the focus. See How do I detect the currently focused application?

Community
  • 1
  • 1
Kuishi
  • 157
  • 4
  • But note that the running time of a process doesn't directly help with the goal, because the process might not have the focus. – GreenAsJade Jan 17 '14 at 23:15