mirror of
https://github.com/moraroy/NonSteamLaunchers-On-Steam-Deck.git
synced 2024-12-21 23:31:52 +01:00
revert if needed, Directly sending json info to plugin
This commit is contained in:
parent
d2f6991d44
commit
9890c629c8
@ -1023,33 +1023,36 @@ if new_shortcuts_added or shortcuts_updated:
|
|||||||
|
|
||||||
# Assuming 'games' is a list of game dictionaries
|
# Assuming 'games' is a list of game dictionaries
|
||||||
games = [shortcut for shortcut in shortcuts['shortcuts'].values()]
|
games = [shortcut for shortcut in shortcuts['shortcuts'].values()]
|
||||||
|
|
||||||
|
sys.path.append(f"{logged_in_home}/homebrew") # Add the directory containing aiohttp to the Python path
|
||||||
|
import aiohttp
|
||||||
|
import asyncio
|
||||||
|
|
||||||
# Create the path to the output file
|
async def send_data():
|
||||||
output_file_path = f"{logged_in_home}/.config/systemd/user/NSLGameScanner_output.log"
|
# Create a session
|
||||||
|
async with aiohttp.ClientSession() as session:
|
||||||
|
# Connect to the WebSocket
|
||||||
|
async with session.ws_connect('http://localhost:8765') as ws:
|
||||||
|
for game in games:
|
||||||
|
# Skip if 'appname' or 'exe' is None
|
||||||
|
if game.get('appname') is None or game.get('exe') is None:
|
||||||
|
continue
|
||||||
|
|
||||||
# Open the output file in write mode
|
# Create a dictionary to hold the shortcut information
|
||||||
with open(output_file_path, 'w') as output_file:
|
shortcut_info = {
|
||||||
for game in games:
|
'appid': str(game.get('appid')),
|
||||||
# Skip if 'appname' or 'exe' is None
|
'appname': game.get('appname'),
|
||||||
if game.get('appname') is None or game.get('exe') is None:
|
'exe': game.get('exe'),
|
||||||
continue
|
'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
|
||||||
|
}
|
||||||
|
|
||||||
# Create a dictionary to hold the shortcut information
|
# Send the JSON data to the WebSocket
|
||||||
shortcut_info = {
|
await ws.send_json(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
|
# Run the send_data coroutine
|
||||||
message = json.dumps(shortcut_info)
|
asyncio.run(send_data())
|
||||||
print(message, flush=True) # Print to stdout
|
|
||||||
|
|
||||||
# Print the shortcut information to the output file
|
|
||||||
print(message, file=output_file, flush=True)
|
|
||||||
|
|
||||||
print("All finished!")
|
print("All finished!")
|
||||||
|
Loading…
Reference in New Issue
Block a user