AFAICT it's the only way to execute a JSON call from a keyboard-shortcut.
Depending on the setting you want to change, you might have to check the current value of the setting and then decide to which value to change it.
For example the setting for "Update videolibrary on startup" can be set to either
true
or
false
. In order to make your keyboard-shortcut work as kind of a toggle, you might have to write a script which checks the current value first and then decide to which value you want to change it. For example a bash script might look like:
Code:
#!/bin/bash
if [[ ! $(command -v jq) ]]; then
echo "please install jq"
exit 1
fi
current_value=$(curl -s -X POST -H "content-type:application/json" http://127.0.0.1:8080/jsonrpc -u kodi:1234 -d '{"jsonrpc":"2.0","id":1,"method":"Settings.getSettingValue","params":{"setting":"videolibrary.updateonstartup"}}' | jq -r ".result.value")
if [ "$current_value" = "false" ]; then
curl -s -X POST -H "content-type:application/json" http://127.0.0.1:8080/jsonrpc -u kodi:1234 -d '{"jsonrpc":"2.0","id":1,"method":"Settings.SetSettingValue","params":{"setting":"videolibrary.updateonstartup","value":true}}' && curl -s -X POST -H "content-type:application/json" http://127.0.0.1:8080/jsonrpc -u kodi:1234 -d '{"jsonrpc":"2.0","id":1,"method":"gui.shownotification","params":{"title":"foo","message":"set to true"}}'
else
curl -X POST -H "content-type:application/json" http://127.0.0.1:8080/jsonrpc -u kodi:1234 -d '{"jsonrpc":"2.0","id":1,"method":"Settings.SetSettingValue","params":{"setting":"videolibrary.updateonstartup","value":false}}' && curl -s -X POST -H "content-type:application/json" http://127.0.0.1:8080/jsonrpc -u kodi:1234 -d '{"jsonrpc":"2.0","id":1,"method":"gui.shownotification","params":{"title":"foo","message":"set to false"}}'
fi