[mythtv-users] Lirc commands in a shell script

Hika van den Hoven hikavdh at gmail.com
Sun Sep 28 16:14:37 UTC 2014


Hoi Stephen,

Sunday, September 28, 2014, 4:51:18 PM, you wrote:

> On Sun, 28 Sep 2014 15:50:07 +0200, you wrote:

>>
>>
>>> Hoi Stephen,
>>
>>> Sunday, September 28, 2014, 3:28:30 PM, you wrote:
>>
>>>> On Mon, 29 Sep 2014 02:21:21 +1300, you wrote:
>>
>>>>>On Sun, 28 Sep 2014 13:37:09 +0200, you wrote:
>>>>>
>>>>>>Hoi All ,
>>>>>>
>>>>>> I have Radio integrated in Myth with some adaptations as in the wiki.
>>>>>> The radio command (ivtv-radio and aplay) itself runs as an
>>>>>> independent service and I can select stations (with iradio, which can
>>>>>> set the station on the screen or v4l2-ctl) either through a Mythmenu
>>>>>> or through a shellscript. Also Volume (with amixer) I can control
>>>>>> through that script. 
>>>>>> Through my remote I can turn it on and off, by starting/stopping the
>>>>>> service. I would like to also be able to select stations and adjust
>>>>>> volume through the remote. That way I do not need to turn on the
>>>>>> screen. As I have seen suggested, it would be possible to receive
>>>>>> Lirc commands in a shellscript, as long as of cause it's on the
>>>>>> foreground. Does anybody know how to do that?
>>>>>
>>>>>Take a look at irexec - that runs things when triggered by a remote
>>>>>button.  It could be used to send signals to your radio service.  I
>>>>>have some test irexec setup in the MCE remote config I posted on my
>>>>>web server a couple of days ago:
>>>>>
>>>>>   http://www.jsw.gen.nz/mythtv/mythbuntu-devinput-lirc.bz2
>>>>>
>>>>>Look at the end of the "mythtv" file that goes in /home/<your
>>>>>mythfrontend user>/.lirc.  You can make an entire file of irexec setup
>>>>>and add it to the /home/<your mythfrontend user>/.lircrc file to be
>>>>>included in the lirc setup.  Whenever irexec is running, it will get
>>>>>those commands.
>>
>>> Do you mean that I should in .lircrc set prog = irexec for the ones I
>>> want to use in my script? I now run irexec for it is by default
>>> present in the service script, but have all mythtv keys marked with 
>>> prog = mythtv. Then how do I catch them in the script? I guess I put a
>>> while true; do loop around that to trigger when it receives a valid
>>> command.

> You can put script directly in the .lircrc entries for irexec, on the
> config line, or you can call another program or an external script.
> That code would need to somehow send signals to your radio service.

> If you have entries in your .lircrc for different programs for the
> same key, I am not sure if they are all run or only the first one that
> is met is run.  You would need to check the lirc documentation.

>>Or do they come in as regular keystrokes, so I can catch it with read.
>>But then I need a following <Enter>.

> No, the incoming keycodes from lirc are not passed on directly.  The
> .lircrc entry matches a keycode from /usr/include/linux/input.h, and
> for an ordinary program then sends out one or more characters (not
> keycodes) to that program, as specified on the config line.  For
> irexec, the characters it receives from the config line it takes as
> some script code it must execute.  Mythfrontend interprets the
> characters according to its jumppoints and keybindings database tables
> and where it is in its screens (if it is in an alphanumeric entry
> mode, for example).

>>>> I should add that when I run mplayer from mythfrontend for a video
>>>> file that mythfrontend can not play, only mplayer gets the remote
>>>> buttons, not the underlying mythfrontend.  I do not know how that
>>>> works, as if I run irexec in parallel with mythfronted, they both see
>>>> the remote buttons.
>>
>>> I guess that is because then mythfrontend is not the front window.
>>
>>>> Another alternative for changing radio stations is to add them to
>>>> MythTV as channels and use a channel change script to send the change
>>>> station commands to your radio service.  I have that working for my FM
>>>> radio scripts I use with my mothers PVR-150 FM tuner.
>>
>>> If looked at that some time ago, but couldn't get that working. Also
>>> then I probably need my screen on to see what happens.

> In my case, the FM frequency for the PVR-150 tuner is controlled via
> the ivtv-radio command, so it is easy enough to get a channel change
> script to issue the appropriate command based on the freqid value from
> the channel table entry.  When I checked my code just now, I found I
> am in fact doing that from a start recording event script, not a
> channel change script.  I do not think the screen would need to be on
> for that to work.  You would have to set up a key on the remote to go
> to LiveTV mode (a jump table entry that works from everywhere), and
> then you would just key in the channel number once in LiveTV.  I have
> the radio stations as channel numbers 2001, 2002 and up to keep them
> out of the way of any new TV channels.

> I have my radio scripts on my web server if you want to have a look at
> them:

>   http://www.jsw.gen.nz/mythtv/event-start-recording.sh
>   http://www.jsw.gen.nz/mythtv/event-finished-recording.sh

> I am not sure if what I am doing works for LiveTV though - I only use
> it for recording.  I know I have had problems with playing recordings
> while they are still recording, but I do not think I have ever tried
> with LiveTV.
> _______________________________________________

Thanks I'll look at your scripts. One suggestion though. Ones you have
ivtv-radio with aplay running you better change channels through
v4l2-ctl ( v4l2-ctl --device=</dev/radio?> --set-freq=<frequency> )
since ivtv-radio needs to restart when you retune or if you daemonice
then you get a new instance every time you run ivtv-radio.
iradio is a wraparound ivtv-radio that can put tekst on screen through
xosd and has some lirc support. Although I didn't really investigate
the latter. Its documentation is scarce, mostly only that it exists.

Also when again looking at irexec I found that the lirc package also
contains irxevent which does translate to the actual key. I got it to
place a '0' in a xterm. Now I have to test further, if I can get it to
send or include <enter>. Else I can not catch it with read.



Tot mails,
  Hika                            mailto:hikavdh at gmail.com

"Zonder hoop kun je niet leven
Zonder leven is er geen hoop
Het eeuwige dilemma
Zeker als je hoop moet vernietigen om te kunnen overleven!"

De lerende Mens



More information about the mythtv-users mailing list