[mythtv-users] Remote and blaster without LIRC?

Stephen Worthington stephen_agent at jsw.gen.nz
Tue Jun 11 06:50:11 UTC 2019

On Mon, 10 Jun 2019 14:31:55 -0400, you wrote:

>On 6/4/2019 12:50 AM, Stephen Worthington wrote:
>> On Mon, 3 Jun 2019 15:52:10 -0400, you wrote:
>>> This should be working, but it's not; MythTv responds to none of the
>>> button presses from the remote.
>>> Using lirc-setup, when picking mceusb hardware, it pretty much forces
>>> the driver to default, so, I ended up using default. Testing with irw,
>>> it works fine, and returns string  that match the strings in
>>> /etc/lirc/lircd.conf.d/mceusb.lircd.conf.  If I change a string in
>>> mceusb.lircd.conf and retest, I can see the changes in irw.
>>> Testing with ircat, it looks like it's working, but I'm not sure where
>>> the strings are config from.  Some buttons match the contents of
>>> /etc/lirc/lircd.conf.d/mythtv.lircrc, and some don't.  If I change a
>>> string in mythtv.lirc and retest, nothing changes.  I suspect ircat is
>>> getting strings from somewhere else.
>>> Below are the the contents of lircd_options_conf and a couple of
>>> examples; any suggestions on what to look for next?
>>> *Contents of "lircd_options_conf":*
>>> # Generated by lirc-setup
>>> [lircd]
>>> nodaemon = False
>>> driver = default
>>> device = /dev/lirc0
>>> output = /var/run/lirc/lircd
>>> pidfile = /var/run/lirc/lircd.pid
>>> plugindir = /usr/lib/x86_64-linux-gnu/lirc/plugins
>>> permission = 666
>>> allow-simulate = No
>>> repeat-max = 600
>>> lircd_conf = mceusb.lircd.conf
>>> [lircmd]
>>> uinput = False
>>> nodaemon = False
>>> [modinit]
>>> code = echo lirc > /sys/class/rc/rc0/protocols
>>> *example 1:*
>>> don at johnny:~$ irw
>>> 000000037ff07be0 00 KEY_DOWN mceusb
>>> 000000037ff07be0 01 KEY_DOWN mceusb
>>> 000000037ff07be1 00 KEY_UP mceusb
>>> 000000037ff07be1 01 KEY_UP mceusb
>>> ^C
>>> don at johnny:~$
>>> don at johnny:~$ ircat mythtv
>>> Down
>>> Up
>>> *example 2:*
>>> don at johnny:~$ irw
>>> 000000037ff07bdc 00 KEY_BACK mceusb
>>> 000000037ff07bdc 01 KEY_BACK mceusb
>>> ^C
>>> don at johnny:~$ ircat mythtv
>>> Escape
>>> *example 3:*
>>> don at johnny:~$ irw
>>> 000000037ff07bdd 00 KEY_OK mceusb
>>> 000000037ff07bdd 01 KEY_OK mceusb
>>> ^C
>>> don at johnny:~$
>>> don at johnny:~$ ircat mythtv
>>> Return
>>> ^C
>>> don at johnny:~$
>> >From the irw output above, the "default" driver setting is actually
>> using a driver named "mceusb".  The IRW output looks OK, but the arrow
>> keys are not the best ones to use as an example as they also tend to
>> work even without LIRC due to how the other paths for processing IR
>> input work.  The KEY_BACK example though is a key that normally does
>> not work without the LIRC setup being right, so that looks good.
>> The "ircat mythtv" command should be looking at ~/.lircrc for its
>> config file.  On a normal MythTV system, that file is just a set of
>> include commands to read other files.  Here is mine from
>> /home/stephen/.lircrc:
>> stephen at mypvr:~$ cat .lircrc
>> #Custom lircrc generated via mythbuntu-lirc-generator
>> #All application specific lircrc files are within ~/.lirc
>> include ~/.lirc/mythtv
>> include ~/.lirc/mplayer
>> include ~/.lirc/xine
>> include ~/.lirc/vlc
>> include ~/.lirc/xmame
>> include ~/.lirc/xmess
>> include ~/.lirc/totem
>> include ~/.lirc/elisa
>> include ~/.lirc/irexec
>> You need to run ircat from the same user as mythfrontend is run from,
>> in order for it to find the correct .lircrc file.  From the above, it
>> looks like you are doing that, but I can not be completely sure.
>> In the files included from .lircrc, the convention is that each of
>> those files will have the settings for the program that matches the
>> file's name.  So all the settings for mplayer will be in the mplayer
>> file and all the settings for mythtv will be in the mythtv file.
>> However, the way LIRC works is that what matters is what is in each
>> individual setting, so if you get something in a different file that
>> has the settings for mythtv, it will work.  And it could override a
>> valid earlier setting that you have made with a later invalid one.  So
>> you need to watch out for that.  If you are not using any programs
>> other than mythtv with LIRC, and you want to absolutely rule out any
>> problems like that, you can just comment out all the other includes in
>> the .lircrc file by putting a # character at the start of the line.
>> So all the LIRC settings for program "mythtv" should be in
>> ~/.lirc/mythtv.  Settings for program "mythtv" are identified by a
>> "prog = mythtv" line.  Here is my Escape / Back button:
>> begin
>>      remote = devinput
>>      prog = mythtv
>>      button = KEY_BACK
>>      config = Escape
>>      repeat = 0
>>      delay = 0
>> end
>> What that says is when LIRC receives an input from the "devinput"
>> driver, and is attached to program "mythtv", it should translate any
>> "KEY_BACK" signals it receives into the keystroke "Escape" and send
>> that to program "mythtv".  MythTV has settings in mythfrontend that
>> tell it what to do with the keystroke "Escape" when received from
>> LIRC:
>> MariaDB [mythconverg]> select * from keybindings where keylist like
>> '%Esc%';
>> +-------------+------------+----------------------------+---------+----------+
>> | context     | action     | description                | keylist | hostname |
>> +-------------+------------+----------------------------+---------+----------+
>> | Global      | ESCAPE     | Escape                     | Esc     | mypvr    |
>> | Main Menu   | EXITPROMPT | Display System Exit Prompt | Esc     | mypvr    |
>> | Global      | ESCAPE     | Escape                     | Esc     | savaidh  |
>> | Main Menu   | EXITPROMPT | Display System Exit Prompt | Esc     | savaidh  |
>> | TV Playback | BACK       | Exit or return to DVD menu | Esc     | savaidh  |
>> | Global      | ESCAPE     | Escape                     | Esc     | gt70     |
>> | Main Menu   | EXITPROMPT | Display System Exit Prompt | Esc     | gt70     |
>> | TV Playback | BACK       | Exit or return to DVD menu | Esc     | gt70     |
>> +-------------+------------+----------------------------+---------+----------+
>> 8 rows in set (0.00 sec)
>> If you are looking for keys in the database, as well as the
>> "keybindings" table for ordinary key bindings that work only from the
>> specified context, you need to search the "jumppoints" table for the
>> global jump points that work from anywhere (any context) in
>> mythfrontend.  And note that the "keylist" field is a comma separated
>> list of keys, not just a single key.
>> The action in MythTV depends on the context, and the hostname.  Each
>> frontend in the database is identified by its hostname, and the
>> settings can be different for each frontend.  And you can see that in
>> the MythTV settings, the LIRC keystroke "Escape" is spelled "Esc",
>> just to confuse things further.  In mythfrontend GUI, you can find
>> those settings at Setup > Edit Keys.
>> So in your case, to get the Escape / Back remote button to work, you
>> would want this in your ~/.lirc/mythtv file:
>> begin
>>      remote = mceusb
>>      prog = mythtv
>>      button = KEY_BACK
>>      config = Escape
>>      repeat = 0
>>      delay = 0
>> end
>> Note the change in the "remote =" line to "remote = mceusb", as that
>> is the driver name that irw is showing for your setup.  So take a look
>> at your ~/.lirc/mythtv file.  It likely has more than one set of
>> settings in it for "prog = mythtv", each set of setting having a
>> different "remote =" value.  What you need is a full set of those
>> settings, with "remote = mceusb".  Here is what I had in my original
>> ~/.lirc/mythtv file:
>> stephen at mypvr:~/.lirc$  grep "remote =" mythtv.original | uniq
>>      remote = mceusb_hauppauge
>>      remote = vista_mce
>>      remote = mceusb
>> So it is not unlikely that you have a set of "remote = mceusb"
>> settings in your ~/.lirc/mythtv file.  I have long since renamed my
>> original ~/.lirc/mythtv file to ~/.lirc/mythtv.original, and edited a
>> copy of it to suit my system, so I now only have "remote = devinput"
>> settings in it.  I would recommend that you do the same, but only have
>> "remote = mceusb" in your ~/.lirc/mythtv file.  Then you need to go
>> through all the keys on your remote, checking what is output by "ircat
>> mythtv" against that file, and then changing either the Mythfrontend
>> setting for the key to match the file, or the file setting in the
>> "config =" line to match Mythfrontend.  I recommend keeping the
>> Mythfrontend settings and changing the "config =" settings, as the
>> Mtyhfrontend settings are also what you use from a real keyboard, and
>> the defaults work well from a keyboard.  If you have a remote key that
>> does not produce output in ircat, you will need to create a new
>> begin/end block with the appropriate settings for it, with a "button
>> =" value that matches its irw output.  Each time you change something
>> in ~/.lirc/mythtv, you will need to restart ircat at least, so it will
>> read the new settings.  I am not sure if you also need to restart
>> lircd:
>> sudo systemctl restart lircd
>> I think that is unnecessary, but check to see if you need to.
>> Once you have a set of "remote = mcuusb" settings that work, you can
>> consider the "repeat =" and "delay =" settings for them.  Those
>> control whether a key autorepeats, and how quickly it repeats,
>> respectively.  I have my arrow keys, the channel and volume keys, and
>> PgUp and PgDown set to "repeat = 1" and "delay = 1".  All other keys
>> do not autorepeat.  The "delay = 1" gives the fastest possible
>> autorepeat rate.  But those are just my personal preferences.
>Our installations seem to be a little different from each other.  My 
>lirc_options.config is set to default, and running mceusb.  .lircrc is 
>nowhere to be found on mine.  The .lirc directory is also missing.
>I have .lircrc and .lirc on a working 16.04 machine, so, copied them to 
>this 18.04 machine, as-is.  Now I have:
>don at johnny:~/.lirc$ pwd
>don at johnny:~/.lirc$ ls
>elisa  mplayer  mythtv  mythtv~  mythtv.old  totem  vlc  xine xmame  xmess
>...mythtv has the application button definitions.
>don at johnny:~$ pwd
>don at johnny:~$ cat .lircrc
>#Custom lircrc generated via mythbuntu-lirc-generator
>#All application specific lircrc files are within ~/.lirc
>include ~/.lirc/mythtv
>include ~/.lirc/mplayer
>include ~/.lirc/xine
>include ~/.lirc/vlc
>include ~/.lirc/xmame
>include ~/.lirc/xmess
>include ~/.lirc/totem
>include ~/.lirc/elisa
>Now mythtv responds to the remote, with most buttons working, as 
>expected.  Experimenting with /home/don/.lirc/mythtv, no changes have 
>any effect, so maybe the button setups are coming from somewhere else?

It looks like the $(HOME)/.lircrc setup used to be installed by the
old MythTV Control Center program.  So if, like me, you have been
upgrading since then, you have that setup.  If you install a new
18.04, it is not there.  Copying it from an old machine is probably
the easiest way to get it now.  But when you did that, did you fix the
ownership and permissions?  That could be part of your problem now. So
try running this:

cd /home/don/.mythtv
sudo chown don:don lircrc
chmod u=rw,g=rw,o=r .lircrc
cd .lirc
sudo chown don:don *
chmod u=rw,g=rw,o=r *

>Trying to test with the mythtv user, apparently mthtv is created without 
>a password, so when I su to it, I get an error; unless I use:
>sudo -i -u mythtv
>...then I get other errors; not sure where to take it from here.

Yes, the user "mythtv" is not set up fully, just enough for it to be
usable to run programs such as mythbackend, but it does not have a
password and can not be used as a GUI user.  But user "mythtv" has
nothing to do with mythfrontend - that is run from the user that is
logged in as the GUI user.  In your case, that is user "don".  So what
you need to be doing to test the lirc setup is to be running "ircat
mythtv" from a GUI terminal screen, which will also be running as user

I think if you really need to run things as user "mythtv", you would
need to use:

sudo su mythtv

But you do not need to do that.  The "mythtv" bit on an "ircat mythtv"
command is not a user name.  It is the lirc name used by all MythTV
programs that use lirc, such as mythfrontend, mythtv-setup.real,
mythavtest and so on.  They all have the lirc name "mythtv" programmed
into their source code to use when they attempt to connect to lirc.
That allows them all to use the same lirc setup referenced by the
"mythtv" name, instead of having to each have a separate setup under
their executable file name.

>don at johnny:~$ sudo -i -u mythtv
>[sudo] password for don:
>-sh: 2: [: x: unexpected operator
>-sh: 2: [: x: unexpected operator
>$ pwd
>$ ircat mythtv
>mythtv: could not open config files /home/mythtv/.lircrc and 
>mythtv: No such file or directory
>How do I find the correct button setup file?

You look at your mythfrontend.log file (in /var/log/mythtv).  Looking
at mine with this command:

grep -i lirc /var/log/mythtv/mythfrontend.log

I get lots of lines that look like this:

Jun 11 06:30:10 mypvr mythfrontend.real: mythfrontend[3957]: I
CoreContext lirc.cpp:319 (Init) LIRC: Successfully initialized
'/dev/lircd' using '/home/stephen/.mythtv/lircrc' config

So mythfrontend is looking at the file $(HOME)/.mythtv/lircrc when it
loads its lirc settings.  So when I look there, I can see this:

root at mypvr:~# ll /home/stephen/.mythtv/lir*
lrwxrwxrwx 1 stephen stephen    15 Aug 23  2014
/home/stephen/.mythtv/lircrc -> ../.lirc/mythtv*
-rw-rw-r-- 1 stephen stephen 16978 Aug 23  2014

So the $(HOME)/.mythtv/lircrc file is a link to $(HOME)/.lircrc. Which
will be the thing that is missing in your setup, as I had completely
forgotten about it and never told you to set it up.  To fix that:

cd ~/.mythtv
ln -s ../.lircrc lircrc

More information about the mythtv-users mailing list