Change Kodi setting with keyboard shortcut
#1
I'm looking for a way to define a keyboard shortcut that would change a Kodi setting and display notification about the change. I haven't found anything related to changing settings in list of built-in functions so I figured I can use System.Exec builtin to run a program that will call JSON-RPC Settings.SetSettingValue and GUI.ShowNotification methods. Is this the right approach here or perhaps it can be done easier (without writing external program)?
Reply
#2
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
Reply

Logout Mark Read Team Forum Stats Members Help
Change Kodi setting with keyboard shortcut0