steamtracker

package
v2.16.1 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: GPL-3.0 Imports: 15 Imported by: 0

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

View Source
const DefaultPollInterval = 2 * time.Second

DefaultPollInterval is the default interval for game state scanning.

Variables

This section is empty.

Functions

func FindGamePID

func FindGamePID(gamePath string) (int, bool)

FindGamePID finds a running process that matches the game executable path.

func FindGamePIDForAppID added in v2.16.0

func FindGamePIDForAppID(steamDir string, appID int, gamePath string) (int, bool)

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

func FindGamePIDWithProcPath(procPath, gamePath string) (int, bool)

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

type GameStartCallback func(appID int, pid int, gamePath string)

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

type ReaperProcess struct {
	GamePath string
	PID      int
	AppID    int
}

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

type TrackedGame struct {
	StartTime time.Time
	GamePath  string
	AppID     int
	PID       int
}

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) Start

func (t *Tracker) Start()

Start begins monitoring for Steam games.

func (*Tracker) Stop

func (t *Tracker) Stop()

Stop stops the game tracker.

func (*Tracker) TrackedGames

func (t *Tracker) TrackedGames() []TrackedGame

TrackedGames returns a copy of currently tracked games.

Jump to

Keyboard shortcuts

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