Last active
October 24, 2023 20:23
-
-
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.
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
#!/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