steamtracker

package
v2.9.1 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 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 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 to find an exact match for the game executable, then falls back to searching for any process in 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 (reaper on Linux, game on Windows), gamePath is the game executable path.

type GameStopCallback

type GameStopCallback func(appID int)

GameStopCallback is called when a Steam game exits. appID is the Steam App ID that was running.

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),
) *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