thyme: Index | Files

package thyme

import ""


Package Files

darwin.go data.go linux.go list.go show.go

func List Uses

func List(stream *Stream)

func RegisterTracker Uses

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

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

func Stats Uses

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

type AggTime Uses

type AggTime struct {
    Charts []*BarChart

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

func NewAggTime Uses

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

NewAggTime returns a new AggTime created from a Stream.

type Bar Uses

type Bar struct {
    Label string
    Count int

Bar represents a single bar in a bar chart.

type BarChart Uses

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 Uses

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 Uses

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 Uses

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

Plus adds n to the count associated with the label.

type DarwinTracker Uses

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 Uses

func (t *DarwinTracker) Deps() string

func (*DarwinTracker) Snap Uses

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

type LinuxTracker Uses

type LinuxTracker struct{}

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

func (*LinuxTracker) Deps Uses

func (t *LinuxTracker) Deps() string

func (*LinuxTracker) Snap Uses

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

type Range Uses

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

Range represents a labeled range of time.

type Snapshot Uses

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 Uses

func (s Snapshot) Print() string

Print returns a pretty-printed representation of the snapshot.

type Stream Uses

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) Print Uses

func (s Stream) Print() string

Print returns a pretty-printed representation of the snapshot.

type Timeline Uses

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 Uses

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 Uses

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 Uses

func NewDarwinTracker() Tracker

func NewLinuxTracker Uses

func NewLinuxTracker() Tracker

func NewTracker Uses

func NewTracker(name string) Tracker

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

type Window Uses

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 Uses

func (w *Window) Info() *Winfo

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


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 Uses

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

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

func (*Window) IsSticky Uses

func (w *Window) IsSticky() bool

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

func (*Window) IsSystem Uses

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 Uses

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 Uses

func (w Winfo) Print() string

Print returns a pretty-printed representation of the snapshot.

Package thyme imports 12 packages (graph). Updated 2020-07-21. Refresh now. Tools for package owners.