Trigger script if update is available

I’d like to be able to trigger a bash script when an OSMC update is available. I’ve been looking through the source code for update_service.py and wanted to check if I’m on the right track.

If I base my trigger on creation of the file /var/tmp/.suppress_osmc_update_checks, will this work? Is this file created when updates are available, or only when updates have been downloaded?

Thanks in advance.

That won’t work. /var/tmp/.suppress_osmc_update_checks is only created if new updates are found AND the user declined to install them when prompted.

This is just a flag to keep track of the fact that updates were already offered to the user and they declined them, so we don’t keep bugging the user over and over. (For example if you have a daily schedule set you don’t have to keep saying no every day to the same update you don’t want yet)

When that flag exists automated update checks are suspended. When updates are finally installed (through the manual option) the flag file is deleted so that automated update checks can resume.

For the answer to your question you’ll need to wait for @Karnage to reply as the updater is his baby and no-one else understands it as well as he does… :wink:

OK, makes sense. Thanks. I may need to interrogate some internal setting linked to the ‘update available’ icon but I’ll wait and see what @Karnage has to say.

What you want is to check a variable stored in the Kodi Home window:

if xbmcgui.Window(10000).getProperty('OSMC_notification') == 'true':

Note; that will only work if you have the Home screen notification switched on in the Update settings.

unattended-upgrades is my favorite :smiley:

apt-get install -y unattended-upgrades
dpkg-reconfigure unattended-upgrades

might not be recommended for everyone but for this works out just fine :smiley:

Thanks @Karnage. I now need to see how/if this is possible from the command line using JSON-RPC. Off to Google…

I’m now a bit stuck…

I’ve got this far in putting together the appropriate command:

curl --data-binary '{"jsonrpc": "2.0", "method": "GUI.GetProperties", "params": NOT SURE WHAT GOES IN HERE, "id": 1}' -H 'content-type: application/json;' http://localhost/jsonrpc

Does anyone have a tip on what I should be including in the “params” section of the call in order to (I’m assuming here) retrieve the value of OSMC_notification from within Window ID 10000?