steamtracker

package
v2.23.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: GPL-3.0 Imports: 16 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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) ForgetIgnoredGames added in v2.18.0

func (pi *PlatformIntegration) ForgetIgnoredGames()

ForgetIgnoredGames re-tests the games being tracked against the ignore predicate and drops the ones that now match.

Core can learn that a Steam game is really its own frontend after the fact. The frontend registers as a launch host a moment after Steam starts it, and Core restarting underneath a frontend that is already running reverses the order entirely: the game is detected first and the registration arrives second. Without this the frontend lands in the user's play history and Resume points back at their own launcher.

func (*PlatformIntegration) IgnoreExecutable added in v2.17.0

func (pi *PlatformIntegration) IgnoreExecutable(path string)

IgnoreExecutable prevents an internal Steam-owned helper shortcut from becoming user-visible ActiveMedia. Matching is exact after path cleaning.

func (*PlatformIntegration) IgnoreProcessTree added in v2.18.0

func (pi *PlatformIntegration) IgnoreProcessTree(owns func(reaperPID int) bool)

IgnoreProcessTree prevents a Steam game from becoming user-visible ActiveMedia when its reaper owns a process Core has a use for.

The frontend is the case: Steam starts it like any other app, but it is a launcher, not something the user played, so recording it would put "Steam Game <id>" in their history and point Resume back at their own frontend. Matched by process rather than by path because a frontend started through a wrapper script reports the interpreter as its executable.

The predicate is called with the tracker lock held, so it must not reach back into the tracker.

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