Need a good tutorial for mapping the green button on my MCE remote to "Launch Kodi"
#1
Remote: http://windowsdevcenter.com/windows/2006...fig-21.jpg

I found few tutorials but they were all at least 4 years old. I'm hoping for something more current. 
 
bash:
$ cat /etc/lsb-release 

DISTRIB_ID=LinuxMint

DISTRIB_RELEASE=18

DISTRIB_CODENAME=sarah

DISTRIB_DESCRIPTION="Linux Mint 18 Sarah"

I want to be able to press the green button in the middle of the remote to re-launch Kodi, in case it stops running (which happens at least twice a week).
Reply
#2
You need to setup the remote with lirc on-top of devinput, then use irexec to launch Kodi. The tutorials are that old because not much has changed in this space.
Reply
#3
What you need to do is this:  First install the lirc package from a Linux command prompt:  sudo apt install lirc

Do this from the command prompt because it should pop up a menu asking you to select the type of remote you have from a list (it will also ask if you have an IR transmitter, but chances are you don't).  If you have a Windows Media Center (Windows MCE) compatible remote, that will be down near the bottom of the list.

If for some reason you don't get the questions, or you make a mistake or get a different remote, run  sudo dpkg-reconfigure lirc  from a command prompt to get the configuration menu back again.

Then you will need to use nano or another text editor to create a text file in your user home directory with the filename .lircrc (note the leading dot character).  It should contain a section that looks something like this:

begin
 prog = irexec
 button = KEY_GREEN
 config = ~/startkodi.sh &
 repeat = 0
end


Note that KEY_GREEN is the button name in Windows MCE compatible remotes, but other remotes may use a different name - more on that in a minute.

The above will call a bash script named startkodi.sh which should also be in your user home directory.  I would post what it should contain here, but when I try I get a message saying: Sorry, you have been blocked You are unable to access kodi.tv, so you'll need to go to https://pastebin.ca/3964987 to see it.

The above script tries to see if Kodi is already running and if it is it kills it, trying more aggressive methods each time.  It then waits three seconds and restarts it (or starts it for the first time if it's not already running).  A normal startup command would be kodi --standalone & (the & allows the script to continue to complettion) but it's also possible to use other options as shown in the commented-out lines.  For example, pasuspender is supposed to suspend pulseaudio, not sure if it really works but it doesn't appear to hurt anything, and then in the next line AE_SINK=ALSA forces Kodi to use ALSA audio (which for some people works better than pulse audio, especially on "passthrough" audio) and nice -20 allows Kodi to use as much of the CPU as it needs, which can sometimes help avoid video glitches on low-powered systems.  I'm not saying you should or shouldn't use any of those, just pointing out that it's possible from a startup script of this kind.  Feel free to modify the script as you wish for your own needs.

Don't forget to replace yourusername at the top of the script with your actual user name on the system (same as the user name for your home directory).  And also, don't forget to change the permissions on the script to make it executable, or it won't work (I always seem to forget that and then spend two hours trying to figure out why a script won't work, and feel like such a dummy afterwards.  That why I emphasize it!).

All of the above is done from the Linux command prompt. But then you also need to go into your desktop and bring up the Startup Applications Preferences window, and click Add and add a new startup application:

Name: irexec
Command: irexec -d
Comment: Infrared Controller

Then reboot the system and try pushing the green button and see if it brings up or restarts Kodi.  If it doesn't, it may be that
KEY_GREEN is not the correct button name for your remote.  Go back to the Linux command prompt and execute the irw program. When it is running, every time you press a button on the remote you should see one or more lines appear on the screen, that will contain the button name for that button.  Whatever name appears will be what you need to use in .lircrc
Reply

Logout Mark Read Team Forum Stats Members Help
Need a good tutorial for mapping the green button on my MCE remote to "Launch Kodi"0