Last active
January 29, 2020 02:34
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://pypi.org/project/vdf/