steam

package
v2.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const FlatpakSteamID = "com.valvesoftware.Steam"

FlatpakSteamID is the Flatpak app ID for Steam.

Variables

View Source
var (
	ErrInvalidMagic   = errors.New("invalid appinfo.vdf magic header")
	ErrAppNotFound    = errors.New("app not found in appinfo.vdf")
	ErrInvalidFormat  = errors.New("invalid binary VDF format")
	ErrNoLaunchConfig = errors.New("no launch config found")
)

Functions

func BuildSteamDetailsURL

func BuildSteamDetailsURL(id string) string

BuildSteamDetailsURL builds a Steam details page URL from a game ID. This opens the game's details page in the Steam client library.

func BuildSteamURL

func BuildSteamURL(id string) string

BuildSteamURL builds a Steam launch URL from a game ID.

func DefaultSteamAppsDirs

func DefaultSteamAppsDirs() []string

DefaultSteamAppsDirs returns default locations for Steam's steamapps directory. These are platform-specific paths where Steam is commonly installed.

func ExtractAndValidateID

func ExtractAndValidateID(path string) (string, error)

ExtractAndValidateID extracts and validates the Steam game ID from a virtual path. Returns the numeric ID or an error if the path is invalid or ID is non-numeric.

func ExtractAppIDFromPath

func ExtractAppIDFromPath(path string) (int, bool)

ExtractAppIDFromPath extracts an AppID from a Steam virtual path. Path format: "steam://[id]/[name]" or "steam://rungameid/[id]"

func FindAppNameByAppID

func FindAppNameByAppID(appID int) (string, bool)

FindAppNameByAppID searches common Steam locations for an app's name. This is a convenience function that tries multiple locations.

func FindInstallDirByAppID

func FindInstallDirByAppID(appID int) (string, bool)

FindInstallDirByAppID searches common Steam locations for an app's install directory. Returns the full path to the game's install directory (e.g., /path/to/steamapps/common/GameName).

func FindSteamAppsDir

func FindSteamAppsDir(steamDir string) string

FindSteamAppsDir finds the steamapps directory from a Steam root directory. It checks for both lowercase and mixed-case "steamapps" directories.

func FormatGameName

func FormatGameName(appID int, name string) string

FormatGameName returns a formatted game name for display. If the name is found, returns it; otherwise returns "Steam Game {AppID}".

func GetGameExecutable

func GetGameExecutable(steamDir string, appID int) (string, bool)

GetGameExecutable returns the best executable path for the current OS. It reads appinfo.vdf to find the launch configuration. Returns the full path to the executable, or empty string if not found.

func LookupAppName

func LookupAppName(steamAppsDir string, appID int) (string, bool)

LookupAppName finds the name of a Steam app by its AppID. Returns the app name and true if found, or empty string and false if not. steamAppsDir should point to the steamapps directory (e.g., ~/.steam/steam/steamapps).

func LookupAppNameInLibraries

func LookupAppNameInLibraries(steamAppsDir string, appID int) (string, bool)

LookupAppNameInLibraries searches all Steam library folders for an app. steamAppsDir should point to the main steamapps directory.

func NewSteamLauncher

func NewSteamLauncher(opts Options) platforms.Launcher

NewSteamLauncher creates a configurable Steam launcher.

func NormalizePath

func NormalizePath(path string) string

NormalizePath normalizes Steam URL formats to the standard virtual path format. Converts "steam://rungameid/123" to "steam://123".

func ScanSteamApps

func ScanSteamApps(steamDir string) ([]platforms.ScanResult, error)

ScanSteamApps scans official Steam games from the libraryfolders.vdf file. steamDir should point to the steamapps directory (e.g., ~/.steam/steam/steamapps).

func ScanSteamShortcuts

func ScanSteamShortcuts(steamDir string) ([]platforms.ScanResult, error)

ScanSteamShortcuts scans Steam shortcuts (non-Steam games) from the shortcuts.vdf file. steamDir should point to the Steam root directory.

Types

type AppInfo

type AppInfo struct {
	Name       string
	InstallDir string
	AppID      int
}

AppInfo contains metadata for a Steam app from its manifest.

func ReadAppManifest

func ReadAppManifest(steamAppsDir string, appID int) (AppInfo, bool)

ReadAppManifest reads a Steam app manifest and returns its info. steamAppsDir should point to the steamapps directory.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client implements SteamClient for Steam game launching and scanning.

func NewClient

func NewClient(opts Options) *Client

NewClient creates a new Steam client with the given options.

func NewClientWithExecutor

func NewClientWithExecutor(opts Options, cmd command.Executor) *Client

NewClientWithExecutor creates a new Steam client with a custom command executor. This is useful for testing.

func (*Client) FindSteamDir

func (c *Client) FindSteamDir(cfg *config.Instance) string

FindSteamDir locates the Steam installation directory on Linux.

func (*Client) IsSteamInstalled

func (c *Client) IsSteamInstalled(cfg *config.Instance) bool

IsSteamInstalled checks if Steam is installed by verifying the Steam directory exists. Uses FindSteamDir to locate the directory, respecting config overrides.

func (*Client) Launch

func (c *Client) Launch(
	_ *config.Instance, path string, opts *platforms.LaunchOptions,
) (*os.Process, error)

Launch launches a Steam game on Linux using xdg-open or the direct steam command.

func (*Client) ScanApps

func (*Client) ScanApps(steamDir string) ([]platforms.ScanResult, error)

ScanApps scans Steam library for installed official apps. steamDir should point to the steamapps directory (e.g., ~/.steam/steam/steamapps).

func (*Client) ScanShortcuts

func (*Client) ScanShortcuts(steamDir string) ([]platforms.ScanResult, error)

ScanShortcuts scans Steam for non-Steam games (user-added shortcuts). steamDir should point to the Steam root directory.

type LaunchConfig

type LaunchConfig struct {
	Executable string // Relative executable path (e.g., "game.exe")
	Arguments  string // Launch arguments
	Type       string // Launch type ("default", "none", "option1", etc.)
	OSList     string // Target OS ("windows", "linux", "macos")
	WorkingDir string // Relative working directory
}

LaunchConfig contains launch configuration from appinfo.vdf.

func ReadLaunchConfigs

func ReadLaunchConfigs(steamDir string, appID int) ([]LaunchConfig, error)

ReadLaunchConfigs reads launch configurations for an app from appinfo.vdf.

type Options

type Options struct {
	// FallbackPath is used if Steam directory detection fails.
	// Linux examples: "/home/deck/.steam/steam", "/usr/games/steam"
	// Windows example: "C:\\Program Files (x86)\\Steam"
	FallbackPath string

	// ExtraPaths are additional paths to check for Steam installation.
	// Only used on Linux; ignored on Windows.
	ExtraPaths []string

	// UseXdgOpen uses xdg-open for launching (desktop-friendly).
	// When false, uses direct `steam` command (console/Game Mode friendly).
	// Only used on Linux; ignored on Windows.
	UseXdgOpen bool

	// CheckFlatpak enables checking for Flatpak Steam installation.
	// Only used on Linux; ignored on Windows.
	CheckFlatpak bool
}

Options configures Steam client behavior across all platforms.

func DefaultBazziteOptions

func DefaultBazziteOptions() Options

DefaultBazziteOptions returns settings for Bazzite (Fedora Atomic gaming distro).

func DefaultChimeraOSOptions

func DefaultChimeraOSOptions() Options

DefaultChimeraOSOptions returns optimized settings for ChimeraOS.

func DefaultDarwinOptions

func DefaultDarwinOptions() Options

DefaultDarwinOptions returns sensible defaults for macOS.

func DefaultLinuxOptions

func DefaultLinuxOptions() Options

DefaultLinuxOptions returns sensible defaults for desktop Linux.

func DefaultSteamOSOptions

func DefaultSteamOSOptions() Options

DefaultSteamOSOptions returns optimized settings for SteamOS/Steam Deck.

func DefaultWindowsOptions

func DefaultWindowsOptions() Options

DefaultWindowsOptions returns sensible defaults for Windows.

type SteamClient

type SteamClient interface {
	// FindSteamDir locates the Steam installation directory.
	// Returns the path to the Steam root directory or the fallback path.
	FindSteamDir(cfg *config.Instance) string

	// IsSteamInstalled checks if Steam is installed by verifying the Steam directory exists.
	// Uses FindSteamDir to locate the directory, respecting config overrides.
	IsSteamInstalled(cfg *config.Instance) bool

	// Launch launches a Steam game by its virtual path.
	// Path format: "steam://[id]/[name]" or "steam://rungameid/[id]"
	// Returns nil for fire-and-forget launches (Steam handles the process).
	// The opts parameter is optional and may be nil.
	Launch(cfg *config.Instance, path string, opts *platforms.LaunchOptions) (*os.Process, error)

	// ScanApps scans Steam library for installed official apps.
	// steamAppsDir should point to the steamapps directory (e.g., ~/.steam/steam/steamapps).
	ScanApps(steamAppsDir string) ([]platforms.ScanResult, error)

	// ScanShortcuts scans Steam for non-Steam games (user-added shortcuts).
	// steamDir should point to the Steam root directory.
	ScanShortcuts(steamDir string) ([]platforms.ScanResult, error)
}

SteamClient defines the interface for Steam operations. This interface enables proper mocking and TDD for Steam integration.

Directories

Path Synopsis
Package steamtracker provides Steam game lifecycle tracking on Linux.
Package steamtracker provides Steam game lifecycle tracking on Linux.

Jump to

Keyboard shortcuts

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