Skip to content

Instantly share code, notes, and snippets.

@HackerHarry
Created January 3, 2026 18:40
Show Gist options
  • Select an option

  • Save HackerHarry/67a2191283e7382f79043c9a314355f9 to your computer and use it in GitHub Desktop.

Select an option

Save HackerHarry/67a2191283e7382f79043c9a314355f9 to your computer and use it in GitHub Desktop.
Send Kodi back Home from TV-Channel selection
#!/usr/bin/env bash
#
# since Kodi needs more CPU time on my Raspberry Pi while displaying live TV
# channels overview and EPG data, i want it to return to the home screen once
# the screen saver kicks in. i run more than just Kodi on my Pi's.
# this script is obviously designed for a German UI and needs jq & netcat.
# i run it via cron at a regular interval
iPORT=9090
sHOST=localhost
# RPC interface available?
jRESULT=$(echo '{"jsonrpc":"2.0","method":"JSONRPC.Ping","id":1}' | nc $sHOST $iPORT | jq -r '.result')
if [ "$jRESULT" != "pong" ]; then
# no pong... get outta here
exit 1
fi
# screen saver active?
jRESULT=$(echo '{"jsonrpc":"2.0","method":"XBMC.GetInfoBooleans","params":{"booleans":["System.ScreenSaverActive"]},"id":1}' | nc $sHOST $iPORT | jq -r '.result."System.ScreenSaverActive"')
if [ "$jRESULT" = "false" ]; then
# Kodi is in use
exit 0
fi
# are we at the live TV screen? (German "TV-Sender")
jRESULT=$(echo '{"jsonrpc":"2.0","method":"GUI.GetProperties","params":{"properties": ["currentwindow"]},"id":1}' | nc $sHOST $iPORT | jq -r '.result.currentwindow.label')
if [ "$jRESULT" != "TV-Sender" ]; then
# nope, get out
exit 0
fi
# send Kodi to the Home screen, nevermind the result
# need to send it twice, since the first attempt only revives the UI
jRESULT=$(echo '{"jsonrpc":"2.0","method":"Input.Home","id":1}' | nc $sHOST $iPORT &>/dev/null)
sleep 2
jRESULT=$(echo '{"jsonrpc":"2.0","method":"Input.Home","id":1}' | nc $sHOST $iPORT &>/dev/null)
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment