Simple busy / idle time tracker inspired by the ancient article Inactivity and Idle Time on OS X.
According to the article, OS X has a timer called HIDIdleTime that tracks the last time you interacted with the computer, e.g. moved the mouse, typed a key, or interacted with the computer.
billy-idle simply queries this value periodically using the ioreg
utility that ships with macOS, and matches it against a pre-defined threshold. If exceeded, it will create a record for the busy time period in database. This data can later be used as input for time tracking tools or statistics.
$ go run main.go
2024/09/28 00:43:52 [BigMac] π¬ billy-idle tracker started version=latest commit=e95d72f
2024/09/28 00:44:09 [BigMac] π€ Entering idle mode after 17s of busy time, completing record #1
2024/09/28 00:44:13 [BigMac] π Resuming busy mode after 4s of idle time, creating new record #2
2024/09/28 00:44:27 [BigMac] π€ Entering idle mode after 14s of busy time, completing record #2
2024/09/28 00:45:25 [BigMac] π Resuming busy mode after 58s of idle time, creating new record #3
2024/09/28 00:45:37 [BigMac] π€ Entering idle mode after 12s of busy time, completing record #3
2024/09/28 00:45:45 [BigMac] π Resuming busy mode after 8s of idle time, creating new record #4
2024/09/28 00:45:48 [BigMac] π Received Signal interrupt
2024/09/28 00:45:49 [BigMac] π tracker stopped
Note
|
Binary packages for macOS amd64 and arm64 are coming soon, the same goes for docker images on ghcr.io |
$ billy-idle help
-cmd string
Command to retrieve HIDIdleTime (default "ioreg")
-idle duration
Max time before client is considered idle (default 10s)
-interval duration
Interval to check for idle time (default 2s)
Billy Idle currently only support a local sqlite database, more precisely modernc.org/sqlite
which is a cgo-free port of SQLite. But it shouldnβt be a big deal to add support for a remote PostgreSQL Database.
$ make
Usage: make <OPTIONS> ... <TARGETS>
Available targets are:
build build all targets
clean Clean output directory
help Shows the help
lint Lint go code
minor Create Minor Release
run Run tracker
test Test go code
update Update all go dependencies
Source: Wikimedia Commons, terms of the Free Art License apply.
If you want to contribute to rubin please have a look at the CONTRIBUTING.md