I'll help you write a Python script that uses the Steam-Metadata-Editor repository's code to create a new launch entry for CS:GO (AppID 730). Here's a script that demonstrates this:
python
from appinfo import Appinfo
import os
def add_launch_option(appid, description, executable, working_dir, arguments, platforms):
# Get Steam path (this is an example - modify for your system)
if os.name == 'nt': # Windows
steam_path = "C:\\Program Files (x86)\\Steam"
else: # Linux/Mac
steam_path = os.path.expanduser("~/.local/share/Steam")
# Path to appinfo.vdf
vdf_path = os.path.join(steam_path, "appcache", "appinfo.vdf")
# Initialize Appinfo object
appinfo = Appinfo(vdf_path)
# Get current launch options
launch_options = appinfo.get_data_from_section(appid, "config", "launch")
# If no launch options exist, create empty dict
if not launch_options:
appinfo.set_data_from_section(appid, {}, "config", "launch")
launch_options = {}
# New launch option number will be the length of current options
new_option_number = str(len(launch_options))
# Create new launch option
appinfo.set_data_from_section(appid, description, "config", "launch", new_option_number, "description")
appinfo.set_data_from_section(appid, executable, "config", "launch", new_option_number, "executable")
appinfo.set_data_from_section(appid, working_dir, "config", "launch", new_option_number, "workingdir")
appinfo.set_data_from_section(appid, arguments, "config", "launch", new_option_number, "arguments")
appinfo.set_data_from_section(appid, platforms, "config", "launch", new_option_number, "config", "oslist")
# Update the app data
appinfo.update_app(appid)
# Write changes to disk
appinfo.write_data()
def main():
# CS:GO AppID
appid = 730
# Example launch option configuration
description = "CS:GO Custom Launch"
executable = "csgo.exe" # The game's executable
working_dir = "" # Empty means use default
arguments = "-novid -tickrate 128 -high" # Example launch arguments
platforms = "windows,linux" # Supported platforms
try:
add_launch_option(appid, description, executable, working_dir, arguments, platforms)
print("Successfully added new launch option!")
except Exception as e:
print(f"Error adding launch option: {e}")
if __name__ == "__main__":
main()
This script:
Creates a function add_launch_option that handles adding a new launch entry to Steam's appinfo.vdf file
Uses the Appinfo class from the Steam-Metadata-Editor repository to handle reading and writing to the VDF file
Takes parameters for:
Game AppID (730 for CS:GO)
Description for the launch option
Executable path
Working directory
Launch arguments
Supported platforms
Automatically determines the next available launch option number
Writes the changes to the appinfo.vdf file
To use this script:
Make sure you have the Steam-Metadata-Editor repository's code accessible
Place this script in the same directory as the repository's source files
Run the script with appropriate permissions (Steam must be closed)
Modify the parameters in the main() function to match your desired configuration
Important notes:
Make sure Steam is closed before running the script
Back up your appinfo.vdf file before making modifications
You may need to run the script with administrator/root privileges
The exact paths may need to be adjusted for your system
The executable path should be relative to the game's installation directory
The script uses example values for CS:GO - you can modify the arguments and other parameters in the main() function to match your specific needs.
Ah, I see the error. Looking at the repository code, I made a mistake. The method is part of the MainWindow class, not the Appinfo class. Let me correct the script:
python
from appinfo import Appinfo
import os
def add_launch_option(appid, description, executable, working_dir, arguments, platforms):
# Get Steam path (this is an example - modify for your system)
if os.name == 'nt': # Windows
steam_path = "C:\\Program Files (x86)\\Steam"
else: # Linux/Mac
steam_path = os.path.expanduser("~/.local/share/Steam")
# Path to appinfo.vdf
vdf_path = os.path.join(steam_path, "appcache", "appinfo.vdf")
# Initialize Appinfo object
appinfo = Appinfo(vdf_path)
# Get current launch options or create if doesn't exist
try:
launch_options = appinfo.parsedAppInfo[appid]["sections"]["appinfo"]["config"]["launch"]
except KeyError:
# Initialize the structure if it doesn't exist
if appid not in appinfo.parsedAppInfo:
print(f"Error: AppID {appid} not found in appinfo.vdf")
return
if "config" not in appinfo.parsedAppInfo[appid]["sections"]["appinfo"]:
appinfo.parsedAppInfo[appid]["sections"]["appinfo"]["config"] = {}
if "launch" not in appinfo.parsedAppInfo[appid]["sections"]["appinfo"]["config"]:
appinfo.parsedAppInfo[appid]["sections"]["appinfo"]["config"]["launch"] = {}
launch_options = appinfo.parsedAppInfo[appid]["sections"]["appinfo"]["config"]["launch"]
# New launch option number will be the length of current options
new_option_number = str(len(launch_options))
# Create new launch option structure
launch_options[new_option_number] = {
"description": description,
"executable": executable,
"workingdir": working_dir,
"arguments": arguments,
"config": {
"oslist": platforms
}
}
# Update the app data
appinfo.update_app(appid)
# Write changes to disk
appinfo.write_data()
def main():
# CS:GO AppID
appid = 730
# Example launch option configuration
description = "CS:GO Custom Launch"
executable = "csgo.exe" # The game's executable
working_dir = "" # Empty means use default
arguments = "-novid -tickrate 128 -high" # Example launch arguments
platforms = "windows,linux" # Supported platforms
try:
add_launch_option(appid, description, executable, working_dir, arguments, platforms)
print("Successfully added new launch option!")
except Exception as e:
print(f"Error adding launch option: {e}")
if __name__ == "__main__":
main()
The key changes in this corrected version:
Instead of using get_data_from_section, we now directly access the data structure through parsedAppInfo
Added proper error handling for cases where the config structure doesn't exist
Creates the necessary dictionary structure if it doesn't exist
Directly modifies the parsed VDF data structure instead of using helper methods
To use this script:
Make sure Steam is closed
Place this script in the same directory as the Steam-Metadata-Editor source files
Run the script with appropriate permissions
Verify the changes in Steam after reopening it
You may need to adjust the Steam path according to your system's configuration. Also, make sure you have a backup of your appinfo.vdf file before running the script.
Note: If you get any other errors, please let me know and I'll help you resolve them. The script might need additional adjustments depending on your specific Steam installation and system configuration.