Documentation
¶
Overview ¶
Package steamtracker provides Steam game lifecycle tracking on Linux. It detects game starts by monitoring Steam's reaper processes and game exits using pidfd/polling.
Index ¶
- Constants
- func FindGamePID(gamePath string) (int, bool)
- func FindGamePIDForAppID(steamDir string, appID int, gamePath string) (int, bool)
- func FindGamePIDForAppIDWithProcPath(procPath, steamDir string, appID int, gamePath string) (int, bool)
- func FindGamePIDWithProcPath(procPath, gamePath string) (int, bool)
- type GameStartCallback
- type GameStopCallback
- type PlatformIntegration
- type ReaperProcess
- type TrackedGame
- type Tracker
Constants ¶
const DefaultPollInterval = 2 * time.Second
DefaultPollInterval is the default interval for game state scanning.
Variables ¶
This section is empty.
Functions ¶
func FindGamePID ¶
FindGamePID finds a running process that matches the game executable path.
func FindGamePIDForAppID ¶ added in v2.16.0
FindGamePIDForAppID finds a process for an AppID using Steam's install and launch metadata before falling back to the reaper-derived path.
func FindGamePIDForAppIDWithProcPath ¶ added in v2.16.0
func FindGamePIDForAppIDWithProcPath( procPath, steamDir string, appID int, gamePath string, ) (int, bool)
FindGamePIDForAppIDWithProcPath is the testable form of FindGamePIDForAppID.
func FindGamePIDWithProcPath ¶
FindGamePIDWithProcPath finds a running process matching the game path using a custom proc path. It first tries an exact executable/argument match, then falls back to a process whose command line or executable is inside the game's install directory.
Types ¶
type GameStartCallback ¶
GameStartCallback is called when a Steam game starts. appID is the Steam App ID. pid is the process ID where available, or a platform lifecycle identifier when the OS does not expose one. gamePath is the game executable path.
type GameStopCallback ¶
type GameStopCallback func(appID, pid int)
GameStopCallback is called when a Steam game exits. pid identifies the stopped process or platform lifecycle instance.
type PlatformIntegration ¶
type PlatformIntegration struct {
// contains filtered or unexported fields
}
PlatformIntegration provides common game tracking integration for Steam-based platforms. It handles game start/stop callbacks and ActiveMedia management.
func NewPlatformIntegration ¶
func NewPlatformIntegration( scanner *procscanner.Scanner, base *linuxbase.Base, activeMedia func() *models.ActiveMedia, setActiveMedia func(*models.ActiveMedia), steamRoots ...string, ) *PlatformIntegration
NewPlatformIntegration creates a new platform integration for game tracking.
func (*PlatformIntegration) Start ¶
func (pi *PlatformIntegration) Start()
Start begins monitoring for Steam games.
func (*PlatformIntegration) Stop ¶
func (pi *PlatformIntegration) Stop()
Stop stops the game tracker.
type ReaperProcess ¶
ReaperProcess represents a running Steam game detected via its reaper process.
func ScanReaperProcesses ¶
func ScanReaperProcesses() ([]ReaperProcess, error)
ScanReaperProcesses finds all Steam reaper processes and their AppIDs. Steam wraps game launches: ~/.local/share/Steam/ubuntu12_32/reaper SteamLaunch AppId=XXXXX -- [cmd]
func ScanReaperProcessesWithProcPath ¶
func ScanReaperProcessesWithProcPath(procPath string) ([]ReaperProcess, error)
ScanReaperProcessesWithProcPath scans for reaper processes using a custom proc path. This allows testing with mock filesystems.
type TrackedGame ¶
TrackedGame represents a currently tracked Steam game.
type Tracker ¶
type Tracker struct {
// contains filtered or unexported fields
}
Tracker monitors Steam game lifecycle events on Linux.
func New ¶
func New(scanner *procscanner.Scanner, onStart GameStartCallback, onStop GameStopCallback) *Tracker
New creates a new game tracker. scanner must be a running process scanner. onStart is called when a game starts, onStop is called when a game exits.
func (*Tracker) TrackedGames ¶
func (t *Tracker) TrackedGames() []TrackedGame
TrackedGames returns a copy of currently tracked games.