Skip to content

Instantly share code, notes, and snippets.

@knoopx
Created April 11, 2025 21:46
Show Gist options
  • Save knoopx/bfa9e544ee12b04ee4519ccb3e05a818 to your computer and use it in GitHub Desktop.
Save knoopx/bfa9e544ee12b04ee4519ccb3e05a818 to your computer and use it in GitHub Desktop.
/home/deck/.steam/steam/userdata/%ID%/config
#!/usr/bin/env python3
import os
import sys
import vdf
import shlex
def remove_broken_shortcuts(vdf_path):
# Load the shortcuts.vdf file using Valve's vdf library.
with open(vdf_path, 'rb') as f:
data = vdf.binary_load(f)
# Ensure the expected "shortcuts" key exists.
if 'shortcuts' not in data:
print("No shortcuts found in the VDF file.")
return
shortcuts = data['shortcuts']
valid_shortcuts = {}
# Iterate over the shortcuts by their keys.
for key, shortcut in shortcuts.items():
exe_path = shortcut.get('Exe')
exe_args = shlex.split(exe_path)
exe_path = exe_args[-1]
if exe_path and os.path.exists(exe_path):
valid_shortcuts[key] = shortcut
else:
appname = shortcut.get('AppName', 'Unknown')
print(f"Removing broken shortcut: {appname} (exe: {exe_path})")
# Replace the shortcuts with the filtered (valid) ones.
data['shortcuts'] = valid_shortcuts
# Write the updated data back to the file.
with open(vdf_path, 'wb') as f:
vdf.binary_dump(data, f)
print("Updated the shortcuts file.")
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: python remove_broken_shortcuts.py /path/to/shortcuts.vdf")
sys.exit(1)
shortcuts_file = sys.argv[1]
if not os.path.exists(shortcuts_file):
print(f"Error: File not found: {shortcuts_file}")
sys.exit(1)
remove_broken_shortcuts(shortcuts_file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment