<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Mar 9, 2019 at 6:39 PM Stephen Worthington <<a href="mailto:stephen_agent@jsw.gen.nz" target="_blank">stephen_agent@jsw.gen.nz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Sat, 9 Mar 2019 14:17:50 -0800, you wrote:<br>
<br>
>On Sat, Mar 9, 2019 at 1:20 PM Allen Edwards <<a href="mailto:allen.p.edwards@gmail.com" target="_blank">allen.p.edwards@gmail.com</a>><br>
>wrote:<br>
><br>
>><br>
>><br>
>> On Fri, Mar 8, 2019 at 6:57 PM Stephen Worthington <<br>
>> <a href="mailto:stephen_agent@jsw.gen.nz" target="_blank">stephen_agent@jsw.gen.nz</a>> wrote:<br>
>><br>
>>> One alternative is to use lirc to assign a button on your remote to<br>
>>> kill mythfrontend.real.  Lirc can be set up to run scripts using<br>
>>> irexec.  The script would do a ps -e and find any running copies of<br>
>>> mythbackend.real and kill them.  Then the mythfrontend script would<br>
>>> see that mythfrontend.real had died and would restart it.<br>
>>><br>
>><br>
>><br>
>Stephen<br>
>I have tried this without success.  Here is what I did.<br>
>1) I modified a key config action to escape<br>
>2) I verified that the key was now the escape key<br>
>3) I  modified the same key definition to run irexec and changed the config<br>
>action to "killall mythfrontend.real"<br>
>4) The key did nothing. Myth did not close and the pid did not change<br>
>5) I copied the config action to a terminal and it killed mythfrontend<br>
><br>
>By the way, myth does not restart when I kill it.<br>
><br>
>This is not exactly what you told me to do but it seemed like it should<br>
>work.<br>
<br>
>Correction: What I did was verify that I could change a key and test it,<br>
>then put an action that I verified would kill mythfrontend in and set the<br>
>key to irexec. Didn't do anything.<br>
<br>
Lirc runs irexec, not a key setting in MythTV.  In /home/<mythfrontend<br>
user>, you should find a file .lircrc that looks something like this:<br>
<br>
root@mypvr:/home/stephen# cat .lircrc<br>
#Custom lircrc generated via mythbuntu-lirc-generator<br>
#All application specific lircrc files are within ~/.lirc<br>
include ~/.lirc/mythtv<br>
include ~/.lirc/mplayer<br>
include ~/.lirc/xine<br>
include ~/.lirc/vlc<br>
include ~/.lirc/xmame<br>
include ~/.lirc/xmess<br>
include ~/.lirc/totem<br>
include ~/.lirc/elisa<br>
include ~/.lirc/irexec<br>
<br>
That is the file that lirc loads by default to set up all its<br>
keystrokes.  By convention, a separate file is used for the setup for<br>
each program that uses lirc, but the actual specification of the<br>
programs is done on the "prog =" lines inside those files, so you can<br>
mix setting for different programs in one lirc config file if you<br>
like.  My remote is using the devinput driver, so for a lirc key<br>
config to do anything, it needs a "remote = devinput" line.  Here are<br>
the first three key configs in my /home/stephen/.lirc/mythtv file:<br>
<br>
begin<br>
    remote = devinput<br>
    prog = mythtv<br>
             # Guide key<br>
    button = KEY_EPG<br>
#    config = S<br>
    config = Ctrl+Alt+G<br>
    repeat = 0<br>
    delay = 0<br>
end<br>
<br>
begin<br>
    remote = devinput<br>
    prog = mythtv<br>
    button = KEY_EXIT<br>
    config = Escape<br>
    repeat = 0<br>
    delay = 0<br>
end<br>
<br>
begin<br>
    remote = devinput<br>
    prog = mythtv<br>
    button = KEY_OK<br>
    config = Return<br>
    repeat = 0<br>
    delay = 0<br>
end<br>
<br>
begin<br>
    remote = devinput<br>
    prog = mythtv<br>
    button = KEY_RIGHT<br>
    config = Right<br>
    repeat = 1<br>
    delay = 1<br>
end<br>
<br>
So what the first one of those does is to say that when lirc receives<br>
a KEY_EPG input from the devinput driver, then if the program with the<br>
lirc name "mythtv" is attached to lirc at the time, it should send a<br>
Ctrl-Alt-G keystroke to that program.  Then inside mythfrontend (which<br>
is running with the lirc name "mythtv"), it will receive the<br>
Ctrl-Alt-G keystroke, look up its keystroke configs from the database<br>
and see that (in my setup) it should jump directly to the Programme<br>
Guide:<br>
<br>
MariaDB [mythconverg]> select * from jumppoints where keylist like<br>
'%alt+g%';<br>
+---------------+-------------+------------+----------+<br>
| destination   | description | keylist    | hostname |<br>
+---------------+-------------+------------+----------+<br>
| Program Guide | NULL        | Ctrl+Alt+G | mypvr    |<br>
+---------------+-------------+------------+----------+<br>
1 row in set (0.00 sec)<br>
<br>
<br>
Here is an example with irexec:<br>
<br>
begin<br>
    remote = devinput<br>
    prog = irexec<br>
    button = KEY_YELLOW<br>
    config = echo "This is the Yellow key"<br>
    repeat = 0<br>
    delay = 0<br>
end<br>
<br>
What that does is when a KEY_YELLOW (teletext key) keystroke is<br>
received from the devinput driver, then if irexec is running and<br>
attached to lirc, then send irexec the keys in the "config =" line. So<br>
irexec will receive a line of text containing the echo command, which<br>
it will then execute.  For this to do anything, you need to be running<br>
irexec in the background as the same user that mythfrontend runs from.<br>
I think you said you are running Ubuntu 16.04, so the best way to run<br>
irexxec there is from systemd.  But the lirc package in 16.04 does not<br>
set that up for you.  In 18.04 the package installs a<br>
/lib/systemd/system/irexec.service file for you to modify to make this<br>
work:<br>
<br>
root@mypvr:/lib/systemd/system# cat irexec.service<br>
[Unit]<br>
Documentation=man:irexec(1)<br>
Documentation=<a href="http://lirc.org/html/configure.html" rel="noreferrer" target="_blank">http://lirc.org/html/configure.html</a><br>
Documentation=<a href="http://lirc.org/html/configure.html#lircrc_format" rel="noreferrer" target="_blank">http://lirc.org/html/configure.html#lircrc_format</a><br>
Description=Handle events from IR remotes decoded by lircd(8)<br>
<br>
[Service]<br>
; user=lirc<br>
; group=lirc<br>
<br>
; Hardening opts, see systemd.exec(5).  Doesn't add much unless<br>
; not running as root. If these are applicable or not depends on<br>
; what commands irexec.lircrc invokes.<br>
;<br>
; NoNewPrivileges=true<br>
; MemoryDenyWriteExecute=true<br>
; PrivateTmp=true<br>
; ProtectHome=true<br>
; ProtectSystem=full<br>
<br>
<br>
Type=simple<br>
ExecStart=/usr/bin/irexec /etc/lirc/irexec.lircrc<br>
<br>
[Install]<br>
WantedBy=multi-user.target<br>
<br>
So what you need to do is to install an irexec.service file for your<br>
system.  The easy way to do that now (as long as the 16.04 systemd<br>
version is late enough, which I think it is), is to run this command:<br>
<br>
sudo systemctl --full edit irexec.service<br>
<br>
I have never used the --full option before, so I do not know what it<br>
will do if the original irexec.service file is not present, so if you<br>
get an error with that command, remove the --full option.  The command<br>
should open your default system editor with the correct irexec.service<br>
file open, which should be empty in your case.  Paste in this text<br>
with the name of your mythfrontend user subsituted in two places:<br>
<br>
[Unit]<br>
Documentation=man:irexec(1)<br>
Documentation=<a href="http://lirc.org/html/configure.html" rel="noreferrer" target="_blank">http://lirc.org/html/configure.html</a><br>
Documentation=<a href="http://lirc.org/html/configure.html#lircrc_format" rel="noreferrer" target="_blank">http://lirc.org/html/configure.html#lircrc_format</a><br>
Description=Handle events from IR remotes decoded by lircd(8)<br>
<br>
[Service]<br>
user=<your mythfronted user><br>
group=mythtv<br>
<br>
; Hardening opts, see systemd.exec(5).  Doesn't add much unless<br>
; not running as root. If these are applicable or not depends on<br>
; what commands irexec.lircrc invokes.<br>
;<br>
; NoNewPrivileges=true<br>
; MemoryDenyWriteExecute=true<br>
; PrivateTmp=true<br>
; ProtectHome=true<br>
; ProtectSystem=full<br>
<br>
<br>
Type=simple<br>
ExecStart=/usr/bin/irexec /home/<your mythfrontend user>/.lirc/irexec<br>
<br>
[Install]<br>
WantedBy=multi-user.target<br>
<br>
Save that and exit from the editor.  Then run these commands:<br>
<br>
sudo systemctl enable irexec.service<br>
sudo systemctl start irexec.service<br>
sudo systemctl status irexec.service<br>
<br>
The status command should show irexec has started and is running.  If<br>
that has not worked, then you will need to fix whatever errors the log<br>
output shows.<br>
<br>
Then you can edit the /home/<your mythfrontend user>/.lirc/irexec file<br>
to put in the commands you want to be able to run from remote buttons.<br>
Each time you change that file, you need to do this command to restart<br>
irexec so it re-reads the config file:<br>
<br>
sudo systemctl restart irexec.service<br>
<br>
If you want to save a little typing, ".service" is what systemctl<br>
defaults to if the unit type is left off, so you can shorten the<br>
systemctl commands like this:<br>
<br>
sudo systemctl restart irexec<br>
<br>
To test if irexec is working properly, set it up with a echo command<br>
like my example, then open a terminal on X and press the remote button<br>
to execute the irexec echo command.  You should see the echo text<br>
appear in the terminal window.  Once that is working, you can try the<br>
"killall mythfrontend.real" command.<br>
<br>
The last time I have actually used irexec like this was in 14.04, so I<br>
have never actually tested the above setup via systemd.  So there<br>
could be a bug or two.<br>
_______________________________________________<br></blockquote><div><br></div><div>Thanks Stemphen for the detailed explanation.  I see now that the edit I did is not working because the users are different. I also see I would need to make quite a few modifications. Seeing all that and your last sentence I think I will focus on getting Myth to startup without adding instances of itself every time there is a restart. I spent most of today trying to figure that out. I have a lead from Ian but don't know what starts myth so can't go further.  I found a shell script that looks like it would start it but it is from 2007 so I am dubious.  </div><div><br></div><div>This thread has forked and I guess that is my fault. The fork has a different subject line so it should be pretty clear.  Did you see that if I do CTRL-ALT-BS 10 times I got 9 instances of mythfrontend running? Whatever is starting myth is not noticing that it is already running.</div><div><br></div><div>Allen</div></div></div>