thyme

package module
v0.0.0-...-f618305 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 18, 2019 License: MIT Imports: 13 Imported by: 0

README

logo Thyme

Spice up your day-to-day productivity with some free Thyme, courtesy of the team at Sourcegraph (the best way to read and explore code). Automatically track which applications you use and for how long.

  • Simple CLI to track and analyze your application usage
  • Detailed charts that let you profile how you spend your time
  • Stores data locally, giving you full control and privacy
  • Open-source, well-documented, and easily extensible

Thyme is a work in progress, so please report bugs! Want to see how it works? Dive into the source here.

Want to share what you've learned about your Thyme? Join the discussion on Twitter.

Features

Simple CLI
  1. Record which applications you use every 30 seconds:

    $ while true; do thyme track -o thyme.json; sleep 30s; done;
    
  2. Create charts showing application usage over time. In a new window:

    $ thyme show -i thyme.json -w stats > thyme.html
    
  3. Open thyme.html in your browser of choice to see the charts below.

Application usage timeline

Application usage timeline

Detailed application window timeline

Application usage timeline

Aggregate time usage by app

Application usage timeline

Dependencies

Thyme's dependencies vary by system. See thyme dep (mentioned in the installation instructions below).

Install

  1. Install Go (if you have Homebrew on macOS, you can also run brew install go) and run

    $ go get -u github.com/sourcegraph/thyme/cmd/thyme
    

    Alternatively, if you don't want to install Go, just download the thyme binary here.

  2. Follow the instructions printed by thyme dep.

    $ thyme dep
    
  3. Verify thyme works with

    $ thyme track
    

    This should display JSON describing which applications are currently active, visible, and present on your system.

Thyme currently supports Linux, macOS, and Windows.

Usage for Other Shells

Windows Powershell
> for(1){thyme track -o thyme.json; Start-Sleep -s 5}
> thyme show -i thyme.json -w stats | Out-File -e utf8 thyme.html
Windows DOS Command Line
> for /L %n in (0) do @(thyme track -o thyme.json && timeout /t 5 /nobreak)
> thyme show -i thyme.json -w stats > thyme.html

Use cases

Thyme was designed for developers who want to investigate their application usage to make decisions that boost their day-to-day productivity.

It can also be for other purposes such as:

  • Tracking billable hours and constructing timesheets
  • Studying application usage behavior in a given population

How is Thyme different from other time trackers?

There are many time tracking products and services on the market. Thyme differs from available offerings in the following ways:

  • Thyme does not intend to be a fully featured time management product or service. Thyme adopts the Unix philosophy of a command-line tool that does one thing well and plays nicely with other command-line tools.

  • Thyme does not require you to manually signal when you start or stop an activity. It automatically records which applications you use.

  • Thyme is open source and free of charge.

  • Thyme does not send data over the network. It stores the data it collects on local disk. It's up to you whether you want to share it or not.

Attribution

The Thyme logo logo by Anthony Bossard is licensed under Creative Commons 3.0.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AggregateSnapshot

func AggregateSnapshot(snapshot *Snapshot)

AggregateSnapshot aggregates snapshot data into SnapData

func List

func List(stream *Stream)

func PrintSnapData

func PrintSnapData() string

PrintSnapData returns snap data as string

func RegisterTracker

func RegisterTracker(name string, t func() Tracker)

RegisterTracker makes a Tracker constructor available to clients of this package.

func Stats

func Stats(stream *Stream) error

Stats renders an HTML page with charts using stream as its data source. Currently, it renders the following charts: 1. A timeline of applications active, visible, and open 2. A timeline of windows active, visible, and open 3. A barchart of applications most often active, visible, and open

Types

type AggTime

type AggTime struct {
	Charts []*BarChart
}

AggTime is the list of bar charts that convey aggregate application time usage.

func NewAggTime

func NewAggTime(stream *Stream, labelFunc func(*Window) string) *AggTime

NewAggTime returns a new AggTime created from a Stream.

type Bar

type Bar struct {
	Label string
	Count int
}

Bar represents a single bar in a bar chart.

type BarChart

type BarChart struct {
	ID     string
	YLabel string
	XLabel string
	Title  string
	Series map[string]int
}

BarChart is a representation of a bar chart.

func NewBarChart

func NewBarChart(id, x, y, title string) *BarChart

NewBarChart returns a new BarChart with the specified ID, x- and y-axis label, and title.

func (*BarChart) OrderedBars

func (c *BarChart) OrderedBars() []Bar

OrderedBars returns a list of the top $maxNumberOfBars bars in the bar chart ordered by decreasing count.

func (*BarChart) Plus

func (c *BarChart) Plus(label string, n int)

Plus adds n to the count associated with the label.

type DarwinTracker

type DarwinTracker struct{}

DarwinTracker tracks application usage using the "System Events" API in AppleScript. Due to the liminations of this API, the DarwinTracker will not be able to detect individual windows of applications that are not scriptable (in the AppleScript sense). For these applications, a single window is emitted with the name set to the application process name and the ID set to the process ID.

func (*DarwinTracker) Deps

func (t *DarwinTracker) Deps() string

func (*DarwinTracker) Snap

func (t *DarwinTracker) Snap() (*Snapshot, error)

type LinuxTracker

type LinuxTracker struct{}

LinuxTracker tracks application usage on Linux via a few standard command-line utilities.

func (*LinuxTracker) Deps

func (t *LinuxTracker) Deps() string

func (*LinuxTracker) Snap

func (t *LinuxTracker) Snap() (*Snapshot, error)

type Range

type Range struct {
	Label string
	Start time.Time
	End   time.Time
}

Range represents a labeled range of time.

type SnapData

type SnapData map[int64]*SnapInfo

SnapData represents window id as key with SnapInfo as information

func (SnapData) GetOrCreate

func (s SnapData) GetOrCreate(key int64) *SnapInfo

GetOrCreate returns snap info with specified key. If key not found, return new SnapInfo object

type SnapInfo

type SnapInfo struct {
	//LastTimestamp is last time the program create snapshot for window
	LastTimestamp time.Time
	//TotalTime is time in Millisecond format
	TotalTime int64
	//WindowName is name of the open window
	WindowName string
}

SnapInfo represents aggregated snapshot information

type Snapshot

type Snapshot struct {
	Time    time.Time
	Windows []*Window
	Active  int64
	Visible []int64
}

Snapshot represents the current state of all in-use application windows at a moment in time.

func (Snapshot) Print

func (s Snapshot) Print() string

Print returns a pretty-printed representation of the snapshot.

type Stream

type Stream struct {
	// Snapshots is a list of window snapshots ordered by time.
	Snapshots []*Snapshot
}

Stream represents all the sampling data gathered by Thyme.

func (*Stream) Add

func (s *Stream) Add(snapshot *Snapshot)

Add adds snapshot to stream

func (*Stream) Dump

func (s *Stream) Dump() string

Dump writes snapshot data into csv friendly format

func (*Stream) Flush

func (s *Stream) Flush(filename string)

Flush flushes snapshots into output file

func (Stream) Print

func (s Stream) Print() string

Print returns a pretty-printed representation of the snapshot.

type Timeline

type Timeline struct {
	Start time.Time
	End   time.Time
	Rows  map[string][]*Range
}

Timeline represents a timeline of application usage. Start is the start time of the timeline. End is the end time of the timeline. Rows is a map where the keys are tags and the values are lists of time ranges. Each row is a distinct sub-timeline.

func NewTimeline

func NewTimeline(stream *Stream, labelFunc func(*Window) string) *Timeline

NewTimeline returns a new Timeline created from the specified Stream. labelFunc is used to determine the ID string to be used for a given Window. If you're tracking events by app, this ID should reflect the identity of the window's application. If you're tracking events by window name, the ID should be the window name.

type Tracker

type Tracker interface {
	// Snap returns a Snapshot reflecting the currently in-use windows
	// at the current time.
	Snap() (*Snapshot, error)

	// Deps returns a string listing the dependencies that still need
	// to be installed with instructions for how to install them.
	Deps() string
}

Tracker tracks application usage. An implementation that satisfies this interface is required for each OS windowing system Thyme supports.

func NewDarwinTracker

func NewDarwinTracker() Tracker

func NewLinuxTracker

func NewLinuxTracker() Tracker

func NewTracker

func NewTracker(name string) Tracker

NewTracker returns a new Tracker instance whose type is `name`.

type Window

type Window struct {
	// ID is the numerical identifier of the window.
	ID int64

	// Desktop is the numerical identifier of the desktop the
	// window belongs to.  Equal to -1 if the window is sticky.
	Desktop int64

	// Name is the display name of the window (typically what the
	// windowing system shows in the top bar of the window).
	Name string
}

Window represents an application window.

func (*Window) Info

func (w *Window) Info() *Winfo

Info returns more structured metadata about a window. The metadata is extracted using heuristics.

Assumptions:

  1. Most windows use " - " to separate their window names from their content
  2. Most windows use the " - " with the application name at the end.
  3. The few programs that reverse this convention only reverse it.

func (*Window) IsOnDesktop

func (w *Window) IsOnDesktop(desktop int64) bool

IsOnDesktop returns true if the window is present on the specified desktop

func (*Window) IsSticky

func (w *Window) IsSticky() bool

IsSticky returns true if the window is a sticky window (i.e. present on all desktops)

func (*Window) IsSystem

func (w *Window) IsSystem() bool

IsSystem returns true if the window is a system window (like "unity-panel" and thus shouldn't be considered an application visible to the end-users)

type Winfo

type Winfo struct {
	// App is the application that controls the window.
	App string

	// SubApp is the sub-application that controls the window. An
	// example is a web app (e.g., Sourcegraph) that runs
	// inside a Chrome tab. In this case, the App field would be
	// "Google Chrome" and the SubApp field would be "Sourcegraph".
	SubApp string

	// Title is the title of the window after the App and SubApp name
	// have been stripped.
	Title string
}

Winfo is structured metadata info about a window.

func (Winfo) Print

func (w Winfo) Print() string

Print returns a pretty-printed representation of the snapshot.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL