Skip to content

Instantly share code, notes, and snippets.

@sonic2kk
Last active October 24, 2023 20:23
Show Gist options
  • Save sonic2kk/64fe27472d7522ce11f7527f6933b242 to your computer and use it in GitHub Desktop.
Save sonic2kk/64fe27472d7522ce11f7527f6933b242 to your computer and use it in GitHub Desktop.
Return each Steam shortcut entry from shortcuts.vdf in hexadecimal, so each value can be individually parsed.
#!/usr/bin/env bash
# shortcuts.vdf starts with different bytes than all other shortcuts, this magic basically translates to: '00shortcuts000030000002',
# where '0000' is spacing, '30' represents the shortcut index (1), '00' is more spacing, and '0002' is the start of the next column
magic_shortcut_filestart="0073686f7274637574730000300002"
magic_shortcut_blockstart="00080800.*?0002" # How all other shortcut blocks start, with 00080800, then the shortcut number (could be 31,32,even higher for more shortcuts, so we don't care about the value between), then 0002 for the next block start
magic_shortcut_blockend="000808" # How all shortcuts end
# Paste in your Steam UserID
steam_userid=""
shortcuts_vdf="$HOME/.steam/root/userdata/${steam_userid}/config/shortcuts.vdf"
# Parse each shortcut block out from the shortcuts.vdf file
mapfile -t steam_shortcuts_hex < <( xxd -p -c 0 "$shortcuts_vdf" | grep -oP "(${magic_shortcut_filestart}|${magic_shortcut_blockstart})\K.*?(?=${magic_shortcut_blockend})" )
for shortcut in "${steam_shortcuts_hex[@]}"; do
printf "$shortcut" | xxd -r -p | tr -d '\0'
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment