is this correct syntax in bash on arch linux using jq to write to the shortcuts .vdf file in steam?
Define the values for the new entries
declare -A entry1=(
[appid]="123456"
[name]="Epic Games"
[Exe]="epicshortcutepicshortcutdirectory"
)
entries=(entry1 entry2)
Assistant
As an AI language model, I cannot fully assess if this script is correct and functional without context on variables and dependencies. However, the syntax appears to be correct according to the Bash documentation. The script is declaring two associative arrays (entry1 and entry2) and a list (entries) holding them, then checking if the shortcuts_vdf_path file exists and updating it using jq to add the entries if applicable.
User
Assistant
The error message parse error: Invalid numeric literal at line 1, column 66 suggests that there is an issue with the numeric literal at line 1, column 66 of the jq command. This could be caused by a formatting error in the jq command, such as an incorrect quotation mark or an invalid escape sequence.
In this case, it looks like the issue might be with the $epicshortcutdirectory variable in the entry1 and entry2 arrays. The variable is enclosed in double quotes, which might be causing the jq command to interpret it as a string rather than a directory path.
Try removing the double quotes around the $epicshortcutdirectory variable and see if that resolves the issue. The Exe values in the entry1 and entry2 arrays should look like this:
"[path_to_launcher]/EpicGamesLauncher.exe"
where [path_to_launcher] is the directory path to the Epic Games Launcher executable.
User
like this?
Define the values for the new entries
declare -A entry1=(
[appid]="123456"
[name]="Epic Games"
[Exe]=epepicshortcutdirectory
)
Assistant
Yes, that's correct. Removing the double quotes around $epicshortcutdirectory in the Exe fields should resolve the issue caused by the invalid numeric literal in the jq command.
User
Assistant
It looks like you are still getting the same error parse error: Invalid numeric literal at line 1, column 66. The issue might not be related to the Exe field anymore. One possible reason for this issue is that the appid variable is a string, and not a numeric value.
Try changing the appid value in entry1 and entry2 arrays to be integer number without quotes, and see if that resolves the issue.
For example:
declare -A entry1=(
[appid]=123456
[name]="Epic Games"
[Exe]=$epicshortcutdirectory
)
declare -A entry2=(
[appid]=789012
[name]="Another Game"
[Exe]=$epicshortcutdirectory
)
Also, double check for any invalid character or white space before or after appid field in the shortcuts.vdf file.
User
this didnt work is there another format for jq?
Define the values for the new entries
declare -A entry1=(
[appid]=123456
[name]=Epic Games
[Exe]=epicshortcutdirectory
)
entries=(entry1 entry2)
Assistant
The format of the jq command looks correct, so the issue might be with the data being passed into it.
In the jq command, you are passing in the values of the name, appid, and Exe fields from the entry1 and entry2 arrays as arguments and using them in the if statement.
One possible reason that you are still getting the error parse error: Invalid numeric literal at line 1, column 66 could be due to some whitespace character or invalid character in your vdf file. It is worth checking that out too.
d
i
r
ec
t
or
y
"
)
d
ec
l
a
r
e
−
Aentry2=
([appid]=
"789012"[name]=
"AnotherGame"[Exe]=
"
Check if the shortcuts_vdf_path exists
if [[ -f "shortcuts_vdf_path" ]]; then
# Update the shortcuts.vdf file using jq
for entry in "{entries[@]}"; do
declare -n e=entryjq−−argappid"{e[appid]}" --arg name "e[name]"−−argExe"{e[Exe]}" 'if (.shortcuts | type == "array") then if (.shortcuts | map(.AppName) | index(name)) then . else .shortcuts |= . + [{"AppUserDefined":{"appid": appid, "name": name}, "AppName": name, "Exe": Exe}] end elif (.shortcuts | type == "object") then if (.shortcuts | map_values(.AppName) | index(name)) then . else .shortcuts |= {(appid): {"AppUserDefined":{"appid": appid, "name": name}, "AppName": name, "Exe": Exe}} end else . end' "shortcuts_vdf_path" > "shortcutsvdfpath.tempshortcuts_vdf_path.temp" "$shortcuts_vdf_path"
done
else
echo "Could not find shortcuts.vdf file"
fi
why am i getting this error? d /home/deck/.steam/root/userdata/106245328 ]]
echo 'The correct steamid3 for the currently logged in user is: 106245328'
The correct steamid3 for the currently logged in user is: 106245328
echo 'The corresponding userdata folder for the currently logged in user is: /home/deck/.steam/root/userdata/106245328'
The corresponding userdata folder for the currently logged in user is: /home/deck/.steam/root/userdata/106245328
if [[ -f "shortcuts_vdf_path" ]]; then
# Update the shortcuts.vdf file using jq
for entry in "{entries[@]}"; do
declare -n e=entryjq−−argappid"{e[appid]}" --arg name "e[name]"−−argExe"{e[Exe]}" 'if (.shortcuts | type == "array") then if (.shortcuts | map(.AppName) | index(name)) then . else .shortcuts |= . + [{"AppUserDefined":{"appid": appid, "name": name}, "AppName": name, "Exe": Exe}] end elif (.shortcuts | type == "object") then if (.shortcuts | map_values(.AppName) | index(name)) then . else .shortcuts |= {(appid): {"AppUserDefined":{"appid": appid, "name": name}, "AppName": name, "Exe": Exe}} end else . end' "shortcuts_vdf_path" > "shortcutsvdfpath.tempshortcuts_vdf_path.temp" "$shortcuts_vdf_path"
done
else
echo "Could not find shortcuts.vdf file"
fi
You can also try running the jq command with a single entry to check if it is working. For example:
jq --arg appid 123456 --arg name 'Epic Games' --arg Exe "/path/to/exe" 'if (.shortcuts | type == "array") then if (.shortcuts | map(.AppName) | index($name)) then . else .shortcuts |= . + [{"AppUserDefined":{"appid": $appid, "name": $name}, "AppName": $name, "Exe": $Exe}] end elif (.shortcuts | type == "object") then if (.shortcuts | map_values(.AppName) | index($name)) then . else .shortcuts |= {($appid): {"AppUserDefined":{"appid": $appid, "name": $name}, "AppName": $name, "Exe": $Exe}} end else . end' /path/to/shortcuts.vdf
If the issue persists, you can try changing the type of appid to a string (enclosed in quotes) in the jq command:
jq --arg appid "123456" --arg name 'Epic Games' --arg Exe "/path/to/exe" 'if (.shortcuts | type == "array") then if (.shortcuts | map(.AppName) | index($name)) then . else .shortcuts |= . + [{"AppUserDefined":{"appid": $appid, "name": $name}, "AppName": $name, "Exe": $Exe}] end elif (.shortcuts | type == "object") then if (.shortcuts | map_values(.AppName) | index($name)) then . else .shortcuts |= {($appid): {"AppUserDefined":{"appid": $appid, "name": $name}, "AppName": $name, "Exe":