selfwatch

package
v0.0.0-...-48d32f4 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultConfigFname = "~/.selfwatch/config.json"

Variables

This section is empty.

Functions

func LoadConfig

func LoadConfig(fname string) *config

Types

type DailyCount

type DailyCount struct {
	Day   string
	Count int64
}

type Event

type Event struct {
	Code   int32
	Window int64
}

type HourlyCount

type HourlyCount struct {
	Hour  string
	Count int64
}

type Recorder

type Recorder struct {
	KeyPress      func(Event)
	KeyRelease    func(Event)
	ButtonPress   func(Event)
	ButtonRelease func(Event)
	// contains filtered or unexported fields
}

func NewRecorder

func NewRecorder() *Recorder

func (*Recorder) Bind

func (recorder *Recorder) Bind() error

func (*Recorder) GetInputFocus

func (r *Recorder) GetInputFocus() C.Window

func (*Recorder) GetWindowAttributes

func (r *Recorder) GetWindowAttributes(window C.Window)

func (*Recorder) ListProperties

func (r *Recorder) ListProperties(window C.Window)

type RemoteSync

type RemoteSync struct {
	Url     string
	Storage *WatchStorage
}

func (*RemoteSync) FlushEvery

func (r *RemoteSync) FlushEvery(seconds float64) chan bool

func (*RemoteSync) FlushKeys

func (s *RemoteSync) FlushKeys() error

func (*RemoteSync) GetLastRowId

func (s *RemoteSync) GetLastRowId() (int64, error)

func (*RemoteSync) SendRows

func (s *RemoteSync) SendRows(rows [][]interface{}) error

type WatchStorage

type WatchStorage struct {
	// contains filtered or unexported fields
}

func NewWatchStorage

func NewWatchStorage(fname string) (*WatchStorage, error)

func (*WatchStorage) BindRecorder

func (s *WatchStorage) BindRecorder(recorder *Recorder, syncDelay float64) error

func (*WatchStorage) CreateSchema

func (s *WatchStorage) CreateSchema() error

func (*WatchStorage) DailyCounts

func (s *WatchStorage) DailyCounts(days int, newDayHour int) ([]DailyCount, error)

func (*WatchStorage) GetLastKeyPress

func (s *WatchStorage) GetLastKeyPress() (*time.Time, int64, error)

func (*WatchStorage) HourlyCounts

func (s *WatchStorage) HourlyCounts(hours int, dayOffset int) ([]HourlyCount, error)

func (*WatchStorage) HourlyCountsForDate

func (s *WatchStorage) HourlyCountsForDate(date string) ([]HourlyCount, error)

func (*WatchStorage) KeyCountsAfterId

func (s *WatchStorage) KeyCountsAfterId(id int64) ([]rowTuple, error)

func (*WatchStorage) SchemaExists

func (s *WatchStorage) SchemaExists() (bool, error)

func (*WatchStorage) SerializeRecentKeyCounts

func (s *WatchStorage) SerializeRecentKeyCounts(id int64) ([][]interface{}, error)

func (*WatchStorage) WeeklyHourlyGrid

func (s *WatchStorage) WeeklyHourlyGrid() (*WeeklyHeatmapResponse, error)

func (*WatchStorage) WriteKeys

func (s *WatchStorage) WriteKeys(keys int) error

func (*WatchStorage) YearlyCounts

func (s *WatchStorage) YearlyCounts(year int, newDayHour int) ([]DailyCount, error)

type WebServer

type WebServer struct {
	Storage    *WatchStorage
	Config     *config
	ListenAddr string
	CommitHash string
	BuildDate  string
}

func NewWebServer

func NewWebServer(storage *WatchStorage, cfg *config, addr, commitHash, buildDate string) *WebServer

func (*WebServer) Start

func (ws *WebServer) Start() error

type WeeklyHeatmapResponse

type WeeklyHeatmapResponse struct {
	StartDate string              `json:"startDate"`
	EndDate   string              `json:"endDate"`
	Data      []WeeklyHourlyCount `json:"data"`
}

type WeeklyHourlyCount

type WeeklyHourlyCount struct {
	Day   string `json:"day"`
	Hour  int    `json:"hour"`
	Count int64  `json:"count"`
}

Jump to

Keyboard shortcuts

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