Skip to content

abyrd/window-title

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

window-title

Automated time tracking using window titles

The objective is to track the title of the focused window and then apply rules to deduce which project is being worked on for how long.

Implementation notes

For this kind of task, both sampling (polling) and event-driven approaches are possible.

This project was inspired by Joachim Breitner's ARBTT, which uses the polling approach.

ARBTT's default sampling frequency is rather low (but can be configured to be higher), and it saves a lot more window information than I need. My inital experiments with a simple polling script using external commands like xprop fell short.

This project adopts the event-driven approach. There are two common libraries for talking to the X server: Xlib and XCB. Both have Python wrappers. This project uses the XCB one, python-xpyb.

Andrew Gallant's excellent xpybutil provides a high-level API on top of python-xpyb for examining EWMH hints and handling X messages. In this post, Andrew provides most of the necessary detail.

As long as the window manager supports EWMH hints, we can listen for PropertyNotify events on the root window indicating that the _NET_ACTIVE_WINDOW property has been modified. This does not detect window name changes (e.g. changing tabs in a web browser or editor) so we need to listen for additional events on the active window.

Installation

First, install the dependencies:

  • XCB Python Binding (xpyb):

    sudo apt-get install python-xpyb
  • Andrew Gallant's Python port of xcb-util (xpybutil):

    git clone https://github.com/BurntSushi/xpybutil
    cd xpybutil
    sudo python setup.py install
  • Development headers for the X11 Screen Saver extension library (libxss-dev)

    sudo apt-get install libxss-dev

Then download and run window-title:

git clone https://github.com/abyrd/window-title
cd window-title
python window-title.py

About

automated time tracking using window titles

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages