Skip to content

Instantly share code, notes, and snippets.

@sonic2kk
Last active October 24, 2023 20:21
Show Gist options
  • Save sonic2kk/83330e5a4ebe9c41568a174c4569b531 to your computer and use it in GitHub Desktop.
Save sonic2kk/83330e5a4ebe9c41568a174c4569b531 to your computer and use it in GitHub Desktop.
Parse value from shortcuts.vdf hexadecimal shortcut entry using the hex start pattern using Bash. Does not work with appid unfortunately, as it has a slightly different format.
#!/usr/bin/env bash
# Get value in shortcut entry hex between start and end patterns, with null byte removed, converted to plaintext
function get_shortcut_column_value {
shortcut_hex="$1"
shortcut_pattern_start="$2"
shortcut_pattern_end="0001"
printf "${shortcut_hex}" | grep -oP "${shortcut_pattern_start}\K.*?(?=${shortcut_pattern_end})" | xxd -r -p | tr -d '\0'
}
# Example to get appname, you'll need to provide your own shortcuts hex block
hex_block=""
appname_start_block="(014170704e616d6500|6170706e616d65)"
get_shortcut_column_value "${hex_block}" "${appname_start_block}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment