Skip to content

Instantly share code, notes, and snippets.

@qguv
Last active January 29, 2020 02:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qguv/fa7fb937173e2e05181e4bbbe194f843 to your computer and use it in GitHub Desktop.
Save qguv/fa7fb937173e2e05181e4bbbe194f843 to your computer and use it in GitHub Desktop.
Start Steam, forcing offline mode without a prompt. Save in your Steam folder, "C:\Program Files (x86)\Steam" on x86_64 Windows.
import os
USERFILE = "config/loginusers.vdf"
OFFLINE_KEYS = ["WantsOfflineMode", "SkipOfflineModeWarning"]
with open(USERFILE, "r") as f:
lines = f.readlines()
with open(USERFILE, "w") as f:
nest = 0
for line in lines:
key = line.strip().split()[0].strip('"')
# skip writing the existing (bad) values of keys related
# to offline functionality
if key in OFFLINE_KEYS:
continue
# keep track of nesting level
if key == "{":
nest += 1
# if we're closing a user section, write correct values
# to the user object
if key == "}":
if nest == 2:
for offline_key in OFFLINE_KEYS:
f.write("\t" * nest)
f.write(f"\"{offline_key}\"\t\"1\"\n")
nest -= 1
f.write(line)
os.execl("Steam.exe", "Steam.exe")
@craftyguy
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment