Wednesday, February 3, 2021

Arbtt, the automatic rule-based time-tracker

What is arbtt?

arbtt is a cross-platform, completely automatic time tracker.

There are lots of time-tracking programs out there that allow you to collect statistics about how you spend your time, which activities are your biggest time-wasters, and so on. However, most of them require explicit action on your part: you have to manually enter what activity or project you're working on, and that has several disadvantages:

  • You need to stop what you're doing to insert the meta-information, and that breaks your concentration;
  • If you are lazy or get annoyed and don't keep updating it, the statistics will be useless
  • You won't be able to catch a little thing like quickly answering an e-mail or looking for the weather report.

arbtt, on the other hand, is a time tracker that gets out of the way. Its core component (arbtt-capture) silently captures data about what you are doing, completely autonomously. No interaction required, no distraction possible. This information is continuously stored in a log file. A separate tool (arbtt-stats) the allows you to investigate this data, at whatever time is convenient to you, by using simple text-based rules.

One big advantage of this approach is that you do not need to know in advance what queries you are interested in. Since the rules are applied in real-time when you are evaluating your data, and not when recording it, your raw data is always intact, and you can add more rules and forgotten special cases later.

Keep in mind that the log file might contain very sensitive private data. Make sure you protect it well.
You can get rid of all logs by deleting ~/.arbtt/capture.log
.

How does it work?

arbtt-capture is a desktop daemon that runs in the background and keeps a continuous log of your activity, by storing at regular intervals which windows are open, which one has the focus and how long it has been since your last action.

From this log, a wealth of statistics can be derived. Here's where the "rule-based" part of the name comes along: arbtt comes with a built-in command-line statistics generator (arbtt-stats) that will, based on very simple but powerful rules you can customize, sift through the raw data and reveal patterns and relevant information.

The rules are specified in a simple text-based format, on a file called "categorize.cfg". Here's an example of a simple categorize.cfg file:

--Convert program executable names to recognizable names
aliases (
  "Navigator"         -> "Firefox",
  "evince"            -> "PDF reader",
  "gedit"             -> "Text editor",
  "totem"             -> "Video player",
)

{
--Mark any samples captured after 5 minutes of inactivity with the "inactive" tag
$idle > 300                     ==> tag inactive,

--Tag each program with its executable name (filtered by the aliases above)
                                    tag Program:$current.program,

--Tag each program with its window title (filtered by the aliases above)
                                    tag Title:$current.title,

$time >=  8:00 && $time < 12:00 ==> tag time-of-day:morning,
$time >= 14:00 && $time < 18:00 ==> tag time-of-day:afternoon,
}

And here's the corresponding output of arbtt-stats -c "Program":

Statistics for category "Program"
=================================
__________________Tag_|_________Time_|_Percentage_
      Program:Firefox |  8d06h20m00s |      49.01
Program:Google Chrome |  3d15h24m00s |      21.60
  Program:Text editor |  1d04h04m00s |       6.94
        Program:Skype |    13h55m00s |       3.44
     Program:Terminal |     9h22m00s |       2.31
   Program:PDF reader |     6h10m00s |       1.52
      Program:Desktop |     5h13m00s |       1.29
 Program:File browser |     4h11m00s |       1.03
 (53 entries omitted) |    22h59m00s |       5.68

Install arbtt

  • Binary installations

  • Debian/Ubuntu:

    arbtt is available both in Debian's and Ubuntu's repositories.

    Install arbtt:

    sudo apt-get install arbtt

    Set it up to start automatically on system startup:

    cp /usr/share/doc/arbtt/examples/arbtt-capture.desktop ~/.config/autostart/

    Start the daemon manually, if you want it to start capturing immediately, rather than at the next system restart:

    (arbtt-capture &)

    Create a minimal categorize.cfg file to allow arbtt-stats to be invoked without errors:

    echo "{\$idle > 60 ==> tag inactive}" > ~/.arbtt/categorize.cfg
  • Windows:
    Download the latest arbtt-setup.exe and follow the setup process as usual. This will set up the capturing daemon, but note that there is no graphical interface. Extracting stats from the data requires running arbtt-stats on the command line. Run arbtt-stats --help for a quick reference; for more detailed information, consult the manual.
  • Source installations

    arbtt can be installed from source either via cabal install or from the source repository.

    Dependencies:

    arbtt depends on several libraries whose development versions (name often suffixed -dev) must be available or the compilation may fail with errors such as X11-1.6.1.2 failed during the configure step; these libraries include:

    • X11, for the X11 Haskell binding (possibly named libx11-dev or xorg-dev in your package manager)
    • PCRE3, for pcre-light (possibly libpcre3-dev)
    • XSS, for arbtt (possibly libxss-dev)
  • From Hackage:

    arbtt has been published on hackage, the Haskell package database. If you have cabal-install available, you can install arbtt by simply running:

    cabal install arbtt
  • Build from repo:

    Download the latest release from the archive. Extract the tarball and run the following commands to build and install the arbtt binaries:

    runhaskell Setup.hs configure
    runhaskell Setup.hs build
    runhaskell Setup.hs install

    If you use GNOME or KDE, you can copy the file "arbtt-capture.desktop" to ~/.config/autostart/. If you didn't do a system-wide installation, you'll probably need to put the full path to arbtt-capture in the Exec line of the .desktop file.

  • Mac OS X support:

    arbtt can run on Mac OS X systems. To compile it, you need to install the pkgconfig and pcre source packages using Homebrew or MacPorts. For Homebrew, you can execute:

    brew install pkgconfig
    brew install pcre

    or for MacPorts:

    sudo port install pkgconfig
    sudo port install pcre

    Then, you can compile arbtt using the usual cabal commands.

    If you use MacPorts and have a linking error, it may be because of a conflict between the system libiconv and the MacPorts libiconv. Execute the following cabal command to resolve the conflict:

    cabal configure --extra-lib-dir=/usr/lib

    When the installation is done, your arbtt binaries will be located in ~/Library/Haskell/bin or ~/.cabal/bin.



from Hacker News https://ift.tt/1sikUb4

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.