Added Pipe Logic

This commit is contained in:
Roy 2024-02-11 21:34:52 -08:00 committed by GitHub
parent 88f395f65b
commit c50461d2e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -906,6 +906,19 @@ if amazon_games:
# Push down when more scanners are added # Push down when more scanners are added
#PipingInfoToDeckyPlugin
PIPE_PATH = "/tmp/NSLGameScanner_pipe"
# Check if the pipe does not exist
if not os.path.exists(PIPE_PATH):
# Create the named pipe
os.mkfifo(PIPE_PATH)
# Define the directory path
dir_path = f"{logged_in_home}/homebrew/plugins/NonSteamLaunchers/"
# Check if the directory exists
if not os.path.exists(dir_path):
# Only write back to the shortcuts.vdf and config.vdf files if new shortcuts were added or compattools changed # Only write back to the shortcuts.vdf and config.vdf files if new shortcuts were added or compattools changed
if new_shortcuts_added or shortcuts_updated: if new_shortcuts_added or shortcuts_updated:
print(f"Saving new config and shortcuts files") print(f"Saving new config and shortcuts files")
@ -915,40 +928,10 @@ if new_shortcuts_added or shortcuts_updated:
with open(f"{logged_in_home}/.steam/root/userdata/{steamid3}/config/shortcuts.vdf", 'wb') as file: with open(f"{logged_in_home}/.steam/root/userdata/{steamid3}/config/shortcuts.vdf", 'wb') as file:
file.write(vdf.binary_dumps(shortcuts)) file.write(vdf.binary_dumps(shortcuts))
# Print the created shortcuts
if created_shortcuts:
print("Created Shortcuts:")
for name in created_shortcuts:
print(name)
# Assuming 'games' is a list of game dictionaries
games = [shortcut for shortcut in shortcuts['shortcuts'].values()]
for game in games:
# Skip if 'appname' or 'exe' is None
if game.get('appname') is None or game.get('exe') is None:
continue
# Create a dictionary to hold the shortcut information
shortcut_info = {
'appid': str(game.get('appid')),
'appname': game.get('appname'),
'exe': game.get('exe'),
'StartDir': game.get('StartDir'),
'icon': f"{logged_in_home}/.steam/root/userdata/{steamid3}/config/grid/{get_file_name('icons', game.get('appid'))}",
'LaunchOptions': game.get('LaunchOptions'),
'GameID': game.get('GameID', "default_game_id") # Use a default value if game_id is not defined
}
# Print the shortcut information in JSON format
print(json.dumps(shortcut_info), flush=True)
print("All finished!")
# Load the configset_controller_neptune.vdf file # Load the configset_controller_neptune.vdf file
with open(controller_config_path, 'r') as f: with open(controller_config_path, 'r') as f:
config = vdf.load(f) config = vdf.load(f)
#Setting Controller Layouts
# Add new entries for the games # Add new entries for the games
for app_id in app_ids: for app_id in app_ids:
config['controller_config'][str(app_id)] = { config['controller_config'][str(app_id)] = {
@ -1028,6 +1011,41 @@ config['controller_config']['twitch'] = {
config['controller_config']['movie-web'] = { config['controller_config']['movie-web'] = {
'workshop': 'controller_neptune_webbrowser.vdf' 'workshop': 'controller_neptune_webbrowser.vdf'
} }
#End of Setting Controller Layouts
# Save the updated config
with open(controller_config_path, 'w') as f: with open(controller_config_path, 'w') as f:
vdf.dump(config, f) vdf.dump(config, f)
# Print the created shortcuts
if created_shortcuts:
print("Created Shortcuts:")
for name in created_shortcuts:
print(name)
# Assuming 'games' is a list of game dictionaries
games = [shortcut for shortcut in shortcuts['shortcuts'].values()]
# Open the pipe for writing
with open(PIPE_PATH, 'w') as pipe:
for game in games:
# Skip if 'appname' or 'exe' is None
if game.get('appname') is None or game.get('exe') is None:
continue
# Create a dictionary to hold the shortcut information
shortcut_info = {
'appid': str(game.get('appid')),
'appname': game.get('appname'),
'exe': game.get('exe'),
'StartDir': game.get('StartDir'),
'icon': f"{logged_in_home}/.steam/root/userdata/{steamid3}/config/grid/{get_file_name('icons', game.get('appid'))}",
'LaunchOptions': game.get('LaunchOptions'),
'GameID': game.get('GameID', "default_game_id") # Use a default value if game_id is not defined
}
# Print the shortcut information in JSON format
message = json.dumps(shortcut_info)
print(message, flush=True) # Print to stdout
pipe.write(message + '\n') # Write to the pipe
print("All finished!")