Skip to content

Instantly share code, notes, and snippets.

@nalf3in
Last active August 21, 2020 19:00
Show Gist options
  • Save nalf3in/9ca08feed874cf13fc87317acd0d54ac to your computer and use it in GitHub Desktop.
Save nalf3in/9ca08feed874cf13fc87317acd0d54ac to your computer and use it in GitHub Desktop.
Python script to disable/enable game profiles in GHub
# Assuming GHub is installed at it's default location
# %%
import os
import json
CONFIG_FILE_PATH = "C:/Users/Jonathan/AppData/Local/LGHUB/settings.json"
LG_HUB_EXE_PATH = "C:/Program Files/LGHUB/lghub.exe"
ENABLE_GAME_PROFILES = False
# %%
# Stopping the lghub process
os.system("TASKKILL /F /IM lghub.exe /T")
# %%
# Loading the json
json_file = open(CONFIG_FILE_PATH, "r+")
data = json.load(json_file)
json_file.close()
# %%
# Modifying the json in memory
for application in data["applications"]["applications"]:
# Doing this to prevent crashing if the application doesn't have a name
try:
if (application["name"] == "APPLICATION_NAME_DESKTOP"):
application["isDisabled"] = False
print(application)
else:
# Always enable the desktop profile
application["isDisabled"] = not ENABLE_GAME_PROFILES
except:
pass
# %%
# Write the modified json to file
with open(CONFIG_FILE_PATH, "w+") as file:
json.dump(data, file)
# %%
# Start lghub
os.startfile(LG_HUB_EXE_PATH)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment