-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Support for --config-dir and CLI arguments
Enables running from anywhere and automation.
Must validate paths (existence, permissions) and handle OS-specific path construction.
Auto-detection of Steam/userdata path
Convenient for users but requires platform-specific logic.
On Windows: registry or common install paths; on Linux/macOS: several Steam directories.
Handle multiple user folders by scanning for .vcfg files and prompting if needed.
Account for .vcfg files appearing only after first CS2 launch.
Interactive fallback
Useful when auto-detect fails.
Detect TTY to decide whether to prompt or exit with a clear error suggesting --config-dir in non-interactive mode.
Refactor path handling
Remove hardcoded cfg_directory; use buffers safely with size checks.
Join paths portably on Windows and POSIX.
Validation and clear messages
Before opening, check each expected file exists; report missing ones.
Echo the resolved config path for user confirmation.
Documentation and examples
Show usage of --config-dir, behavior when omitted, detection order, special cases (multiple accounts, Steam libraries, Linux/macOS).
Backward compatibility
If executable is placed alongside .vcfg files, detect that automatically to preserve existing workflows.
Added complexity and testing
New code: registry reading, folder scanning, argument parsing, TTY detection.
Test on various environments: Windows default/custom Steam installs, Linux/Proton setups, multiple library folders, permission issues.
Define clear behavior for multiple matches or non-TTY scenarios.
Isolate Windows-specific code for cross-compilation considerations.
Modularity and maintainability
Encapsulate detection logic in its own module for future updates.
Keep a simple fallback (--config-dir) if detection breaks.
Possible enhancements
Parse Steam’s libraryfolders.vdf to find additional libraries.
Offer --steam-root so userdata path derives from that.
Check timestamps or locks to confirm .vcfg generation.
Add verbose logging of attempted paths for debugging.
Overall, these ideas improve usability but need careful cross-platform design, clear error handling, and thorough testing before integration.
Issue Text without Bold Markers
Title: Enhancement: Support custom/auto-detected config directory and command-line arguments instead of hardcoded paths
Description
Currently, the main.c file uses a hardcoded config path:
const char cfg_directory[] = "C:\Program Files (x86)\Steam\userdata\USER_NUMBER\730\local\cfg";
This forces the user to move the executable there and replace USER_NUMBER manually. It is error-prone and limits usability.
Motivation
Reduce manual steps and confusion for new users
Allow running the program from any directory
Make the tool more portable and scriptable
Support multiple Steam accounts or custom installs
Enable future cross-platform compatibility (Linux/macOS via Proton)
Proposed Solution
Add command-line argument support
Allow --config-dir for .vcfg location
Optional: --output-dir for where to save autoexec.cfg
Optional: --steam-user-id to disambiguate multiple accounts
Implement auto-detection
On Windows: query registry or check common install paths, then scan userdata subfolders for .vcfg files
On Linux/macOS: search common Steam directories (~/.steam/steam/userdata, ~/.local/share/Steam/userdata, Proton paths)
If multiple matches, prompt the user to choose
Interactive fallback
If detection fails, prompt for manual path entry
Validate presence of all expected .vcfg files before proceeding
Refactor path usage
Remove hardcoded cfg_directory; use a resolved string buffer safely
Join paths portably, e.g.:
snprintf(filepath, sizeof(filepath), "%s%c%s", cfg_directory, PATH_SEPARATOR, file_name[i]);
Improve validation and messaging
Check each input file exists; report missing ones clearly
Echo the chosen config directory before reading or writing
Update documentation
Add examples for using --config-dir and auto-detection
Document detection order and edge cases (multiple accounts, libraries, OS differences)
Benefits
Usable without recompiling or moving files manually
Supports non-default Steam installs and multiple accounts
Reduces confusion over USER_NUMBER
Enables scripting, backups, and config syncing features
Lays groundwork for cross-platform support
Example Usage