game_launcher 1.1.0
Modern Linux game launcher with Steam / Proton / Wine integration
Loading...
Searching...
No Matches
steam_constants.h
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// ==============================================================================
3// steam_constants.h
4// ==============================================================================
5// Centralized constants for Steam integration
6// ==============================================================================
7// This header provides a single source of truth for all Steam-related constants
8// including timeouts, polling intervals, paths, commands, and limits.
9// All values are compile-time constants with zero runtime overhead.
10// ==============================================================================
11
12#pragma once
13
14#include <cstddef>
15
17{
18// ==========================================================================
19// Process Monitoring & State Management
20// ==========================================================================
21
22/// Interval between Steam process status checks
23constexpr int PROCESS_POLL_INTERVAL_MS = 500;
24
25/// Maximum time to wait for Steam to start before timeout
26constexpr int START_TIMEOUT_SEC = 15;
27
28/// Maximum time to wait for Steam to shutdown before timeout
29constexpr int SHUTDOWN_TIMEOUT_SEC = 15;
30
31/// Polling interval when waiting for Steam restart
32constexpr int RESTART_POLL_INTERVAL_MS = 500;
33
34/// Maximum iterations for restart polling (total time = iterations * interval)
35constexpr int RESTART_MAX_ITERATIONS = 20;
36
37/// Delay after Steam shutdown before attempting restart
38constexpr int POST_SHUTDOWN_DELAY_MS = 1000;
39
40// ==========================================================================
41// Game Launch & Detection
42// ==========================================================================
43
44/// Wait time after launching game before checking process status
45constexpr int POST_LAUNCH_WAIT_SEC = 2;
46
47/// Polling interval when verifying game has started
48constexpr int GAME_VERIFY_POLL_MS = 500;
49
50/// Maximum time to wait for game process to appear after launch.
51/// Steam games need extra time because the steam command exits immediately
52/// and the actual game process (reaper) takes several seconds to appear.
53constexpr int GAME_VERIFY_TIMEOUT_SEC = 30;
54
55/// Interval between game process detection scans
57
58/// Grace period for newly launched games before tracking them.
59/// Must be >= GAME_VERIFY_TIMEOUT_SEC to avoid premature removal.
60/// Steam games take variable time to start (Proton shader compilation, etc.)
61constexpr int GAME_GRACE_PERIOD_SEC = 60;
62
63/// Wait time after Steam starts before launching games
64constexpr int STEAM_INIT_WAIT_SEC = 2;
65
66/// Delay when waiting for Steam to start during game launch
68
69/// Maximum time to wait for Steam to start when launching game
70constexpr int STEAM_START_MAX_WAIT_SEC = 10;
71
72// ==========================================================================
73// API & Network Operations
74// ==========================================================================
75
76/// Timeout for Steam Web API HTTP requests
77constexpr int API_TIMEOUT_SEC = 5;
78
79/// Timeout for cover art image downloads
80constexpr int COVER_ART_TIMEOUT_SEC = 5;
81
82/// Timeout for general curl operations
83constexpr int CURL_TIMEOUT_SEC = 5;
84
85// ==========================================================================
86// Resource Limits
87// ==========================================================================
88
89/// Maximum number of uninstalled games to show in library
90constexpr int MAX_UNINSTALLED_GAMES = 100;
91
92/// Buffer size for reading VDF configuration files
93constexpr size_t VDF_READ_BUFFER_SIZE = 4096;
94
95/// Maximum VDF file size to read (safety limit: 10 MB)
96constexpr size_t VDF_MAX_FILE_SIZE = 10 * 1024 * 1024;
97
98// ==========================================================================
99// Steam Installation Paths (relative to HOME)
100// ==========================================================================
101
102/// Primary Steam installation directory
103constexpr const char* STEAM_ROOT_PATH = ".local/share/Steam";
104
105/// Alternative Steam installation (symlink)
106constexpr const char* STEAM_ROOT_ALT1 = ".steam/root";
107
108/// Alternative Steam installation (legacy)
109constexpr const char* STEAM_ROOT_ALT2 = ".steam/steam";
110
111/// Flatpak Steam installation path
112constexpr const char* FLATPAK_STEAM_PATH = ".var/app/com.valvesoftware.Steam/.local/share/Steam";
113
114/// Snap Steam installation path
115constexpr const char* SNAP_STEAM_PATH = "snap/steam/common/.local/share/Steam";
116
117// ==========================================================================
118// System-Wide Paths
119// ==========================================================================
120
121/// System compatibility tools directory (distro-provided)
122constexpr const char* SYSTEM_COMPAT_TOOLS_PATH1 = "/usr/share/steam/compatibilitytools.d";
123
124/// Alternative system compatibility tools directory
125constexpr const char* SYSTEM_COMPAT_TOOLS_PATH2 = "/opt/steam/compatibilitytools.d";
126
127// ==========================================================================
128// Steam Directory Structure (relative to Steam root)
129// ==========================================================================
130
131/// Directory containing installed games
132constexpr const char* STEAMAPPS_DIR = "steamapps";
133
134/// Directory containing compatibility tools
135constexpr const char* COMPAT_TOOLS_DIR = "compatibilitytools.d";
136
137/// Directory containing user-specific data
138constexpr const char* USERDATA_DIR = "userdata";
139
140/// Directory containing global Steam configuration
141constexpr const char* CONFIG_DIR = "config";
142
143/// Directory containing installed games (within steamapps)
144constexpr const char* COMMON_DIR = "common";
145
146/// Directory containing Proton compatibility data
147constexpr const char* COMPATDATA_DIR = "compatdata";
148
149// ==========================================================================
150// Configuration File Names
151// ==========================================================================
152
153/// File containing library folder paths
154constexpr const char* LIBRARY_FOLDERS_VDF = "libraryfolders.vdf";
155
156/// File containing per-user game settings (launch options, playtime)
157constexpr const char* LOCAL_CONFIG_VDF = "localconfig.vdf";
158
159/// File containing global Steam configuration (Proton mappings)
160constexpr const char* CONFIG_VDF = "config.vdf";
161
162/// File containing user login information
163constexpr const char* LOGIN_USERS_VDF = "loginusers.vdf";
164
165/// Prefix for game manifest files
166constexpr const char* APPMANIFEST_PREFIX = "appmanifest_";
167
168/// Suffix for backup configuration files
169constexpr const char* VDF_BACKUP_SUFFIX = ".backup";
170
171// ==========================================================================
172// Shell Commands
173// ==========================================================================
174
175/// Command to check if Steam process is running
176constexpr const char* CMD_CHECK_STEAM = "pgrep -x steam > /dev/null 2>&1";
177
178/// Command to find running Steam games by reaper process
179constexpr const char* CMD_FIND_STEAM_GAMES = "pgrep -a -f '/reaper SteamLaunch AppId=' 2>/dev/null";
180
181/// Command to gracefully shutdown Steam
182constexpr const char* CMD_SHUTDOWN_STEAM = "steam -shutdown";
183
184/// Command to start Steam silently (no window)
185constexpr const char* CMD_START_STEAM_SILENT = "steam -silent";
186
187/// Command prefix for launching Steam games
188constexpr const char* CMD_LAUNCH_STEAM_GAME = "steam -applaunch";
189
190// ==========================================================================
191// VDF Parsing Patterns
192// ==========================================================================
193
194/// Maximum nesting depth for VDF file parsing (prevents infinite loops)
195constexpr int VDF_MAX_NESTING_DEPTH = 32;
196
197/// Characters that indicate VDF section boundaries
198constexpr const char* VDF_OPEN_BRACE = "{";
199constexpr const char* VDF_CLOSE_BRACE = "}";
200
201// ==========================================================================
202// Cache Configuration
203// ==========================================================================
204
205/// Validity period for Proton version cache (seconds)
206constexpr int PROTON_CACHE_VALIDITY_SEC = 300; // 5 minutes
207
208/// Validity period for library scan cache (seconds)
209constexpr int LIBRARY_CACHE_VALIDITY_SEC = 60; // 1 minute
210
211} // namespace SteamConstants
constexpr const char * CMD_START_STEAM_SILENT
Command to start Steam silently (no window).
constexpr int LIBRARY_CACHE_VALIDITY_SEC
Validity period for library scan cache (seconds).
constexpr const char * APPMANIFEST_PREFIX
Prefix for game manifest files.
constexpr int STEAM_INIT_WAIT_SEC
Wait time after Steam starts before launching games.
constexpr int START_TIMEOUT_SEC
Maximum time to wait for Steam to start before timeout.
constexpr int SHUTDOWN_TIMEOUT_SEC
Maximum time to wait for Steam to shutdown before timeout.
constexpr int API_TIMEOUT_SEC
Timeout for Steam Web API HTTP requests.
constexpr int GAME_VERIFY_TIMEOUT_SEC
Maximum time to wait for game process to appear after launch.
constexpr const char * CMD_LAUNCH_STEAM_GAME
Command prefix for launching Steam games.
constexpr const char * STEAM_ROOT_PATH
Primary Steam installation directory.
constexpr int STEAM_START_MAX_WAIT_SEC
Maximum time to wait for Steam to start when launching game.
constexpr const char * STEAM_ROOT_ALT1
Alternative Steam installation (symlink).
constexpr int RESTART_POLL_INTERVAL_MS
Polling interval when waiting for Steam restart.
constexpr const char * SNAP_STEAM_PATH
Snap Steam installation path.
constexpr int CURL_TIMEOUT_SEC
Timeout for general curl operations.
constexpr const char * COMPATDATA_DIR
Directory containing Proton compatibility data.
constexpr size_t VDF_READ_BUFFER_SIZE
Buffer size for reading VDF configuration files.
constexpr const char * SYSTEM_COMPAT_TOOLS_PATH1
System compatibility tools directory (distro-provided).
constexpr int COVER_ART_TIMEOUT_SEC
Timeout for cover art image downloads.
constexpr const char * STEAM_ROOT_ALT2
Alternative Steam installation (legacy).
constexpr const char * SYSTEM_COMPAT_TOOLS_PATH2
Alternative system compatibility tools directory.
constexpr int GAME_VERIFY_POLL_MS
Polling interval when verifying game has started.
constexpr const char * VDF_BACKUP_SUFFIX
Suffix for backup configuration files.
constexpr int POST_SHUTDOWN_DELAY_MS
Delay after Steam shutdown before attempting restart.
constexpr const char * CMD_CHECK_STEAM
Command to check if Steam process is running.
constexpr const char * LOGIN_USERS_VDF
File containing user login information.
constexpr const char * LIBRARY_FOLDERS_VDF
File containing library folder paths.
constexpr const char * CONFIG_DIR
Directory containing global Steam configuration.
constexpr const char * LOCAL_CONFIG_VDF
File containing per-user game settings (launch options, playtime).
constexpr int STEAM_START_CHECK_INTERVAL_MS
Delay when waiting for Steam to start during game launch.
constexpr const char * COMMON_DIR
Directory containing installed games (within steamapps).
constexpr int POST_LAUNCH_WAIT_SEC
Wait time after launching game before checking process status.
constexpr const char * COMPAT_TOOLS_DIR
Directory containing compatibility tools.
constexpr const char * CONFIG_VDF
File containing global Steam configuration (Proton mappings).
constexpr const char * CMD_FIND_STEAM_GAMES
Command to find running Steam games by reaper process.
constexpr int MAX_UNINSTALLED_GAMES
Maximum number of uninstalled games to show in library.
constexpr int GAME_GRACE_PERIOD_SEC
Grace period for newly launched games before tracking them.
constexpr const char * VDF_CLOSE_BRACE
constexpr int RESTART_MAX_ITERATIONS
Maximum iterations for restart polling (total time = iterations * interval).
constexpr int GAME_DETECTION_INTERVAL_SEC
Interval between game process detection scans.
constexpr const char * FLATPAK_STEAM_PATH
Flatpak Steam installation path.
constexpr int PROCESS_POLL_INTERVAL_MS
Interval between Steam process status checks.
constexpr int VDF_MAX_NESTING_DEPTH
Maximum nesting depth for VDF file parsing (prevents infinite loops).
constexpr const char * STEAMAPPS_DIR
Directory containing installed games.
constexpr const char * VDF_OPEN_BRACE
Characters that indicate VDF section boundaries.
constexpr size_t VDF_MAX_FILE_SIZE
Maximum VDF file size to read (safety limit: 10 MB).
constexpr int PROTON_CACHE_VALIDITY_SEC
Validity period for Proton version cache (seconds).
constexpr const char * CMD_SHUTDOWN_STEAM
Command to gracefully shutdown Steam.
constexpr const char * USERDATA_DIR
Directory containing user-specific data.