How to create a KODI entry to run a script?

As a final question:
Is there a way to feed back to the user that the script has executed?
Like showing a brief message on screen somewhere?
I.e. something that can be done inside the script file itself?

kodi-send --action="Notification(header,message[,time,image])"

1 Like

In case the formatting is confusing…

kodi-send -a "Notification(Updating Libraries,,5000)"

As for the earlier question about the button to trigger I suggested the play button on the home window as the only useful thing you can do with that button on those screens (home is all the windows on the main landing page) is pause video or music playing in the background so not a huge loss since if you just hit the back button from there you are in the fullscreenvideo/visualization where the play button would be back to playback controls.

As for the Python requirement it is my understanding that this is required if you were executing through the skin but not for a keymap.

Also if you are editing a keymap there is no reason to restart Kodi for them to take effect as the following is much quicker and elegant…

kodi-send -a reloadkeymaps

Thanks,
I added this to the end of the script:

header="Streams update"
message="Done"
kodi-send --action="Notification(${header},${message})"

The files update OK and I see the message in the upper right corner.
Perfect!
Thanks again!

1 Like

This worked fine on OSMC with Kodi18 towards an LG Smart-TV and its remote.

But when I tried it on a Philips “not so smart TV” and Kodi19 (upgraded OSMC and got Kodi19) and using this in the keys.xml file it does not work:

<keymap>
  <Home>
    <keyboard>
      <play_pause">System.Exec(/home/osmc/bin/getstreamlist)</play_pause>
    </keyboard>
  </Home>
</keymap>

Nothing happens and replacing play_pause with just play does not either.
However the play button itself works fine when playing the video (when not in Home) to start and stop the video playback…
On the Philips TV system I have failed getting the CEC key code for the TV remote play button, but the Kodi name should also work, right?

What am I missing here?

EDIT:
Just to clarify: I have a cron entry to /home/osmc/bin/getstreamlist running every hour at 12 min past the hour and when this triggers the files are updated and I get the message on the Kodi screen.
So it just seems like either the key is not picked up by Kodi or System.Exec on Kodi 19 is not able to run a standard shellscript…

Look close at what you did on the Philips!!! Very close. Just a hint, but maybe the " just might be an issue :wink:

:confused:
Yes I see what you mean, it was an editing mistake when I took out the <key id="xxx">
So I edited it out to now look like this:

<keymap>
  <Home>
    <keyboard>
      <play_pause>System.Exec(/home/osmc/bin/getstreamlist)</play_pause>
    </keyboard>
  </Home>
</keymap>

And then I applied
kodi-send -a reloadkeymaps

But unfortunately nothing still happens when I hit either play or pause on the Home screen…
I also tested
<play>System.Exec(/home/osmc/bin/getstreamlist)</play>
But still no go.

Maybe I really need to restart Kodi?
(No, tested that and it did not work)

Or is Kodi19 (nonworking) different from Kodi18 (working)?

Hi,

Please enable debug logs, reproduce and upload the logs.

Thanks Tom.

So I did this:

  • Settings->System->Logging->Enable debug
  • Back to main menu
  • Power->Reboot
    When Kodi19 was again running:
  • Move selection up-down to check CEC connection is OK
  • Pressed the play button once (no action visible)
  • MyOSMC->Log–>Upload log ( https://paste.osmc.tv/fosubotura )
  • Settings->System->Logging->Disable debug

Back here writing this message.

Is there anything useful in the log?
I found this strange output:

2021-08-20 21:38:50.078 T:457      INFO <general>: Loading special://xbmc/system/keymaps/remote.xml
2021-08-20 21:38:50.090 T:457      INFO <general>: Loading special://xbmc/system/keymaps/touchscreen.xml
2021-08-20 21:38:50.097 T:457      INFO <general>: Loading special://masterprofile/keymaps/keys.xml
2021-08-20 21:38:50.098 T:457     ERROR <general>: Keyboard Translator: Can't find button play
2021-08-20 21:38:50.101 T:457      INFO <general>: Loading special://profile/keymaps/keys.xml
2021-08-20 21:38:50.101 T:457     ERROR <general>: Keyboard Translator: Can't find button play

Has the play button been deprecated?
Right now the content of keys.xml is:

<keymap>
  <Home>
    <keyboard>
      <play>System.Exec(/home/osmc/bin/getstreamlist)</play>
    </keyboard>
  </Home>
</keymap>

UPDATE:
I have now edited the keymap file and put this line in instead:
<play-pause>System.Exec(/home/osmc/bin/getstreamlist)</play-pause>
No go…

Please provide log for this change as well?

Thanks Tom.

There was a typo in my last post, the key ID I added was:
play_pause

Anyway I got the new log prepared:
https://paste.osmc.tv/ehequququv
Here I cannot find play_pause in the text and also not the name of my script…

Sounds like no problem this time, but in general it’s better to reboot twice rather than just once.

Hi,

It’s still seeing global PlayPause, not the home screen update. Could you please clarify which one actually worked on kodi 18:

Or

Thanks Tom.

This is what I have working on the Kodi18 machine in its xml file:

  <Home>
    <keyboard>
      <key id="234">System.Exec(/home/osmc/bin/getstreamlist)</key>
    </keyboard>
  </Home>

This is using the CEC keycode I could extract using the keymap editor for the play key.
This is still working fine on that Kodi18/LG SmartTV combination.
But that Kodi18 nags me every time I start looking at it about the upgrade to Kodi19 and I don’t want to do that until I have resolved the problem on the already upgraded Kodi19 running with the Philips-TV. I am mainly using the LG-TV and so I don’t want to damage it.
What I have now done is to test using <play> and <play_pause> on the Kodi18 system. Does NOT work!
Only the <key id="234"> actually works!
And this is from the LG remote, what key code is sent by the Philips remote play key is unknown by me…
And the upgrade to Kodi19 killed the keymap editor so I cannot find out either.

Hi,

Keymap editor works here for for me on kodi, I would double check its update to date.

Thanks Tom.

You could try key id 230 as some TV’s will send that out instead. I believe with CEC you must use a key id as they don’t map to names the same as other remotes do. Unfortunately CEC shows bogus names in the logs for handlekey events and those names do not work if you try to keymap with them. If that doesn’t work then just uninstall keymap editor and then install it again from Kodi’s repository. It did get updated for Kodi v19. That add-on is by far the easiest way to discover the id’s.

Thanks,
I uninstalled the disabled keymap editor and then installed it again from the main repository. Even though it looks a bit unfamiliar at times it seems to work so I sat down and tried to map out all of the keys on my Philips remote.
Turns out that most keys do not send anything at all to the OSMC box! One example is the play button, which if I try mapping it just returns immediately but with nothing!
Most other keys do not return anything at all and keymap editor returns after the timeout.
So here are the codes that are actually returned:

Stop = 224
Rewind = 226
FastForward = 227
Pause = 230
Play =  (returns immediately but changes nothing)

Play = empty, though it returns immediately upon pressing

Any other of the remote keys either do nothing or switches some TV function which makes Kodi disappear.

Given the above I have now changed the mapping as follows:

<keymap>
  <Home>
    <keyboard>
      <key id="230">System.Exec(/home/osmc/bin/getstreamlist)</key>
    </keyboard>
  </Home>
</keymap>

And now finally it works, even though the play button I use with the LG TV cannot be used so I used pause instead.

Mystery solved! :smile:
And thanks again!

1 Like

What buttons forward via CEC is almost entirely dependent on the TV and is usually a relatively small number. The only exception would be that a TV might allow more or less buttons to be forwarded depending on what CEC device type it sees connected. OSMC (Kodi? not sure) by default identifies as recorder 1. If your really curious search my posts and in the last couple weeks this was brought up for someone that needed to set their unit as player 1 in order for their particular TV to work correctly. I doubt that this path would lead to different result outside of a rare exception, but feel free to try changing it yourself and see if it gets you anywhere.

This means that it is recognizing the button but it is globally mapped to something that Kodi is giving preference to so it tries executing whatever that is instead of letting the add-on map it. One way I’ve found to get around this is by putting the following keymap in and loading it via the terminal. It breaks navigation so once you got the info you needed you just pull it back out and reloadkeymaps again…

Key id notification keymap
<keymap>
	<home>
		<keyboard>
			<key id="1">Notification(id 1,,[50])</key>
			<key id="2">Notification(id 2,,[50])</key>
			<key id="3">Notification(id 3,,[50])</key>
			<key id="4">Notification(id 4,,[50])</key>
			<key id="5">Notification(id 5,,[50])</key>
			<key id="6">Notification(id 6,,[50])</key>
			<key id="7">Notification(id 7,,[50])</key>
			<key id="8">Notification(id 8,,[50])</key>
			<key id="9">Notification(id 9,,[50])</key>
			<key id="10">Notification(id 10,,[50])</key>
			<key id="11">Notification(id 11,,[50])</key>
			<key id="12">Notification(id 12,,[50])</key>
			<key id="13">Notification(id 13,,[50])</key>
			<key id="14">Notification(id 14,,[50])</key>
			<key id="15">Notification(id 15,,[50])</key>
			<key id="16">Notification(id 16,,[50])</key>
			<key id="17">Notification(id 17,,[50])</key>
			<key id="18">Notification(id 18,,[50])</key>
			<key id="19">Notification(id 19,,[50])</key>
			<key id="20">Notification(id 20,,[50])</key>
			<key id="21">Notification(id 21,,[50])</key>
			<key id="22">Notification(id 22,,[50])</key>
			<key id="23">Notification(id 23,,[50])</key>
			<key id="24">Notification(id 24,,[50])</key>
			<key id="25">Notification(id 25,,[50])</key>
			<key id="26">Notification(id 26,,[50])</key>
			<key id="27">Notification(id 27,,[50])</key>
			<key id="28">Notification(id 28,,[50])</key>
			<key id="29">Notification(id 29,,[50])</key>
			<key id="30">Notification(id 30,,[50])</key>
			<key id="31">Notification(id 31,,[50])</key>
			<key id="32">Notification(id 32,,[50])</key>
			<key id="33">Notification(id 33,,[50])</key>
			<key id="34">Notification(id 34,,[50])</key>
			<key id="35">Notification(id 35,,[50])</key>
			<key id="36">Notification(id 36,,[50])</key>
			<key id="37">Notification(id 37,,[50])</key>
			<key id="38">Notification(id 38,,[50])</key>
			<key id="39">Notification(id 39,,[50])</key>
			<key id="40">Notification(id 40,,[50])</key>
			<key id="41">Notification(id 41,,[50])</key>
			<key id="42">Notification(id 42,,[50])</key>
			<key id="43">Notification(id 43,,[50])</key>
			<key id="44">Notification(id 44,,[50])</key>
			<key id="45">Notification(id 45,,[50])</key>
			<key id="46">Notification(id 46,,[50])</key>
			<key id="47">Notification(id 47,,[50])</key>
			<key id="48">Notification(id 48,,[50])</key>
			<key id="49">Notification(id 49,,[50])</key>
			<key id="50">Notification(id 50,,[50])</key>
			<key id="51">Notification(id 51,,[50])</key>
			<key id="52">Notification(id 52,,[50])</key>
			<key id="53">Notification(id 53,,[50])</key>
			<key id="54">Notification(id 54,,[50])</key>
			<key id="55">Notification(id 55,,[50])</key>
			<key id="56">Notification(id 56,,[50])</key>
			<key id="57">Notification(id 57,,[50])</key>
			<key id="58">Notification(id 58,,[50])</key>
			<key id="59">Notification(id 59,,[50])</key>
			<key id="60">Notification(id 60,,[50])</key>
			<key id="61">Notification(id 61,,[50])</key>
			<key id="62">Notification(id 62,,[50])</key>
			<key id="63">Notification(id 63,,[50])</key>
			<key id="64">Notification(id 64,,[50])</key>
			<key id="65">Notification(id 65,,[50])</key>
			<key id="66">Notification(id 66,,[50])</key>
			<key id="67">Notification(id 67,,[50])</key>
			<key id="68">Notification(id 68,,[50])</key>
			<key id="69">Notification(id 69,,[50])</key>
			<key id="70">Notification(id 70,,[50])</key>
			<key id="71">Notification(id 71,,[50])</key>
			<key id="72">Notification(id 72,,[50])</key>
			<key id="73">Notification(id 73,,[50])</key>
			<key id="74">Notification(id 74,,[50])</key>
			<key id="75">Notification(id 75,,[50])</key>
			<key id="76">Notification(id 76,,[50])</key>
			<key id="77">Notification(id 77,,[50])</key>
			<key id="78">Notification(id 78,,[50])</key>
			<key id="79">Notification(id 79,,[50])</key>
			<key id="80">Notification(id 80,,[50])</key>
			<key id="81">Notification(id 81,,[50])</key>
			<key id="82">Notification(id 82,,[50])</key>
			<key id="83">Notification(id 83,,[50])</key>
			<key id="84">Notification(id 84,,[50])</key>
			<key id="85">Notification(id 85,,[50])</key>
			<key id="86">Notification(id 86,,[50])</key>
			<key id="87">Notification(id 87,,[50])</key>
			<key id="88">Notification(id 88,,[50])</key>
			<key id="89">Notification(id 89,,[50])</key>
			<key id="90">Notification(id 90,,[50])</key>
			<key id="91">Notification(id 91,,[50])</key>
			<key id="92">Notification(id 92,,[50])</key>
			<key id="93">Notification(id 93,,[50])</key>
			<key id="94">Notification(id 94,,[50])</key>
			<key id="95">Notification(id 95,,[50])</key>
			<key id="96">Notification(id 96,,[50])</key>
			<key id="97">Notification(id 97,,[50])</key>
			<key id="98">Notification(id 98,,[50])</key>
			<key id="99">Notification(id 99,,[50])</key>
			<key id="100">Notification(id 100,,[50])</key>
			<key id="101">Notification(id 101,,[50])</key>
			<key id="102">Notification(id 102,,[50])</key>
			<key id="103">Notification(id 103,,[50])</key>
			<key id="104">Notification(id 104,,[50])</key>
			<key id="105">Notification(id 105,,[50])</key>
			<key id="106">Notification(id 106,,[50])</key>
			<key id="107">Notification(id 107,,[50])</key>
			<key id="108">Notification(id 108,,[50])</key>
			<key id="109">Notification(id 109,,[50])</key>
			<key id="110">Notification(id 110,,[50])</key>
			<key id="111">Notification(id 111,,[50])</key>
			<key id="112">Notification(id 112,,[50])</key>
			<key id="113">Notification(id 113,,[50])</key>
			<key id="114">Notification(id 114,,[50])</key>
			<key id="115">Notification(id 115,,[50])</key>
			<key id="116">Notification(id 116,,[50])</key>
			<key id="117">Notification(id 117,,[50])</key>
			<key id="118">Notification(id 118,,[50])</key>
			<key id="119">Notification(id 119,,[50])</key>
			<key id="120">Notification(id 120,,[50])</key>
			<key id="121">Notification(id 121,,[50])</key>
			<key id="122">Notification(id 122,,[50])</key>
			<key id="123">Notification(id 123,,[50])</key>
			<key id="124">Notification(id 124,,[50])</key>
			<key id="125">Notification(id 125,,[50])</key>
			<key id="126">Notification(id 126,,[50])</key>
			<key id="127">Notification(id 127,,[50])</key>
			<key id="128">Notification(id 128,,[50])</key>
			<key id="129">Notification(id 129,,[50])</key>
			<key id="130">Notification(id 130,,[50])</key>
			<key id="131">Notification(id 131,,[50])</key>
			<key id="132">Notification(id 132,,[50])</key>
			<key id="133">Notification(id 133,,[50])</key>
			<key id="134">Notification(id 134,,[50])</key>
			<key id="135">Notification(id 135,,[50])</key>
			<key id="136">Notification(id 136,,[50])</key>
			<key id="137">Notification(id 137,,[50])</key>
			<key id="138">Notification(id 138,,[50])</key>
			<key id="139">Notification(id 139,,[50])</key>
			<key id="140">Notification(id 140,,[50])</key>
			<key id="141">Notification(id 141,,[50])</key>
			<key id="142">Notification(id 142,,[50])</key>
			<key id="143">Notification(id 143,,[50])</key>
			<key id="144">Notification(id 144,,[50])</key>
			<key id="145">Notification(id 145,,[50])</key>
			<key id="146">Notification(id 146,,[50])</key>
			<key id="147">Notification(id 147,,[50])</key>
			<key id="148">Notification(id 148,,[50])</key>
			<key id="149">Notification(id 149,,[50])</key>
			<key id="150">Notification(id 150,,[50])</key>
			<key id="151">Notification(id 151,,[50])</key>
			<key id="152">Notification(id 152,,[50])</key>
			<key id="153">Notification(id 153,,[50])</key>
			<key id="154">Notification(id 154,,[50])</key>
			<key id="155">Notification(id 155,,[50])</key>
			<key id="156">Notification(id 156,,[50])</key>
			<key id="157">Notification(id 157,,[50])</key>
			<key id="158">Notification(id 158,,[50])</key>
			<key id="159">Notification(id 159,,[50])</key>
			<key id="160">Notification(id 160,,[50])</key>
			<key id="161">Notification(id 161,,[50])</key>
			<key id="162">Notification(id 162,,[50])</key>
			<key id="163">Notification(id 163,,[50])</key>
			<key id="164">Notification(id 164,,[50])</key>
			<key id="165">Notification(id 165,,[50])</key>
			<key id="166">Notification(id 166,,[50])</key>
			<key id="167">Notification(id 167,,[50])</key>
			<key id="168">Notification(id 168,,[50])</key>
			<key id="169">Notification(id 169,,[50])</key>
			<key id="170">Notification(id 170,,[50])</key>
			<key id="171">Notification(id 171,,[50])</key>
			<key id="172">Notification(id 172,,[50])</key>
			<key id="173">Notification(id 173,,[50])</key>
			<key id="174">Notification(id 174,,[50])</key>
			<key id="175">Notification(id 175,,[50])</key>
			<key id="176">Notification(id 176,,[50])</key>
			<key id="177">Notification(id 177,,[50])</key>
			<key id="178">Notification(id 178,,[50])</key>
			<key id="179">Notification(id 179,,[50])</key>
			<key id="180">Notification(id 180,,[50])</key>
			<key id="181">Notification(id 181,,[50])</key>
			<key id="182">Notification(id 182,,[50])</key>
			<key id="183">Notification(id 183,,[50])</key>
			<key id="184">Notification(id 184,,[50])</key>
			<key id="185">Notification(id 185,,[50])</key>
			<key id="186">Notification(id 186,,[50])</key>
			<key id="187">Notification(id 187,,[50])</key>
			<key id="188">Notification(id 188,,[50])</key>
			<key id="189">Notification(id 189,,[50])</key>
			<key id="190">Notification(id 190,,[50])</key>
			<key id="191">Notification(id 191,,[50])</key>
			<key id="192">Notification(id 192,,[50])</key>
			<key id="193">Notification(id 193,,[50])</key>
			<key id="194">Notification(id 194,,[50])</key>
			<key id="195">Notification(id 195,,[50])</key>
			<key id="196">Notification(id 196,,[50])</key>
			<key id="197">Notification(id 197,,[50])</key>
			<key id="198">Notification(id 198,,[50])</key>
			<key id="199">Notification(id 199,,[50])</key>
			<key id="200">Notification(id 200,,[50])</key>
			<key id="201">Notification(id 201,,[50])</key>
			<key id="202">Notification(id 202,,[50])</key>
			<key id="203">Notification(id 203,,[50])</key>
			<key id="204">Notification(id 204,,[50])</key>
			<key id="205">Notification(id 205,,[50])</key>
			<key id="206">Notification(id 206,,[50])</key>
			<key id="207">Notification(id 207,,[50])</key>
			<key id="208">Notification(id 208,,[50])</key>
			<key id="209">Notification(id 209,,[50])</key>
			<key id="210">Notification(id 210,,[50])</key>
			<key id="211">Notification(id 211,,[50])</key>
			<key id="212">Notification(id 212,,[50])</key>
			<key id="213">Notification(id 213,,[50])</key>
			<key id="214">Notification(id 214,,[50])</key>
			<key id="215">Notification(id 215,,[50])</key>
			<key id="216">Notification(id 216,,[50])</key>
			<key id="217">Notification(id 217,,[50])</key>
			<key id="218">Notification(id 218,,[50])</key>
			<key id="219">Notification(id 219,,[50])</key>
			<key id="220">Notification(id 220,,[50])</key>
			<key id="221">Notification(id 221,,[50])</key>
			<key id="222">Notification(id 222,,[50])</key>
			<key id="223">Notification(id 223,,[50])</key>
			<key id="224">Notification(id 224,,[50])</key>
			<key id="225">Notification(id 225,,[50])</key>
			<key id="226">Notification(id 226,,[50])</key>
			<key id="227">Notification(id 227,,[50])</key>
			<key id="228">Notification(id 228,,[50])</key>
			<key id="229">Notification(id 229,,[50])</key>
			<key id="230">Notification(id 230,,[50])</key>
			<key id="231">Notification(id 231,,[50])</key>
			<key id="232">Notification(id 232,,[50])</key>
			<key id="233">Notification(id 233,,[50])</key>
			<key id="234">Notification(id 234,,[50])</key>
			<key id="235">Notification(id 235,,[50])</key>
			<key id="236">Notification(id 236,,[50])</key>
			<key id="237">Notification(id 237,,[50])</key>
			<key id="238">Notification(id 238,,[50])</key>
			<key id="239">Notification(id 239,,[50])</key>
			<key id="240">Notification(id 240,,[50])</key>
			<key id="241">Notification(id 241,,[50])</key>
			<key id="242">Notification(id 242,,[50])</key>
			<key id="243">Notification(id 243,,[50])</key>
			<key id="244">Notification(id 244,,[50])</key>
			<key id="245">Notification(id 245,,[50])</key>
			<key id="246">Notification(id 246,,[50])</key>
			<key id="247">Notification(id 247,,[50])</key>
			<key id="248">Notification(id 248,,[50])</key>
			<key id="249">Notification(id 249,,[50])</key>
			<key id="250">Notification(id 250,,[50])</key>
			<key id="251">Notification(id 251,,[50])</key>
			<key id="252">Notification(id 252,,[50])</key>
			<key id="253">Notification(id 253,,[50])</key>
			<key id="254">Notification(id 254,,[50])</key>
			<key id="255">Notification(id 255,,[50])</key>
		</keyboard>
	</home>
</keymap>

Really clever solution!
Makes a lot of sense and I am all the time hooked up with the OSMC boxes via SSH (PuTTY) so I can easily do this.
Is the last argument (50) some kind of display timeout in ms for the notification?
Thanks!

Yes, as is specified in Kodi’s keymap wiki that fzinken linked to above. I set it like that to reduce how long the notification was shown. If you trigger a second notification when the previous one is still on screen it can sometimes fail to display. The time shown on screen (at least with the Estuary skin and default settings) is not actually the time set as the in/out transitions are not included in that variable.