<div dir="ltr"><div dir="ltr"><div dir="ltr">On Sun, Mar 10, 2019 at 9:50 AM Allen Edwards <<a href="mailto:allen.p.edwards@gmail.com">allen.p.edwards@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Hi Ian and Stephen,</div><div><br></div><div>You guys were busy as I slept so I am creating a single response.</div><div><br></div><div>As to what I am running this is what I know</div><div><br></div><div><div><b>dad@NewMyth:~$ lsb_release -a</b></div><div><b>No LSB modules are available.</b></div><div><b>Distributor ID: Ubuntu</b></div><div><b>Description:    Ubuntu 16.04.1 LTS</b></div><div><b>Release:        16.04</b></div><div><b>Codename:       xenial</b></div></div><div><br></div><div><br></div><div><div><b>dad@NewMyth:~$ apt-cache policy mythtv</b></div><div><b>mythtv:</b></div><div><b>  Installed: 2:0.28.2+fixes.20180827.9031599-0ubuntu0mythbuntu2</b></div><div><b>  Candidate: 2:0.28.2+fixes.20180827.9031599-0ubuntu0mythbuntu2</b></div><div><b>  Version table:</b></div><div><b> *** 2:0.28.2+fixes.20180827.9031599-0ubuntu0mythbuntu2 500</b></div><div><b>        500 <a href="http://ppa.launchpad.net/mythbuntu/0.28/ubuntu" target="_blank">http://ppa.launchpad.net/mythbuntu/0.28/ubuntu</a> xenial/main i386 Packages</b></div><div><b>        100 /var/lib/dpkg/status</b></div><div><b>     2:0.28.0+fixes.20160413.15cf421-0ubuntu2 500</b></div><div><b>        500 <a href="http://us.archive.ubuntu.com/ubuntu" target="_blank">http://us.archive.ubuntu.com/ubuntu</a> xenial/multiverse i386 Packages</b></div></div><div><br></div><div><br></div><div>And to Ian's question:</div><div><br></div><div><b>dad@NewMyth:~$ ls -la /home/dad/.config/autostart</b></div><div><b>total 16</b></div><div><b>drwxrwxr-x  2 dad dad 4096 Oct 14 09:22 .</b></div><div><b>drwxrwxr-x 12 dad dad 4096 Feb 24 17:14 ..</b></div><div><b>lrwxrwxrwx  1 dad dad   38 Aug 25  2018 mythtv.desktop -> /usr/share/applications/mythtv.desktop</b></div><div><b>-rw-rw-r--  1 dad dad   30 Oct 14 09:19 pulseaudio.desktop</b></div><div><b>-rw-rw-r--  1 dad dad   29 Oct 14 09:22 xfsettingsd.desktop</b></div><div><br></div><div><font color="#a64d79"><br></font></div><div><font color="#a64d79">I must say, I did think your solution of killing mythfrontend via the remote to be a good and elegant one.  Given that a remote is nearly always to hand, it's about as user-friendly as it could be.  So far, we have gone down this rabbit hole a bit - the question now is whether to go further down it or give up...</font></div><div><br></div><div>For a number of reasons having to do with what we are used to, the difficulty of programming and using the remote, and the unknowns of changing the lirc code, I prefer to continue on the CTRL-ALT-BS question as I think we are very close to a solution with all the thought you two have put into this. It could also be of benefit to others if a good solution is found.</div><div><br></div><div><font color="#a64d79">ultimately suggest running mythfrontend without the --service option</font></div><div><br></div><div>If Myth is being run by that script from 2007 that doesn't even run correctly I must ask does myth still crash often enough that the auto restart is necessary?  This seems like a super easy solution unless the underlying program crashes constantly. BTW, I tested it and it works.</div><div><br></div><div>Of course, I may not know if this script is restarting myth but I doubt it as we can see that it does't work.  The crashes I get of myth are freeze up.  Still possible I would not know but worth thought as if the script really is 12 years old then perhaps it is solving a problem that is no longer a problem.</div><div><br></div><div><font color="#a64d79">Clicking on the Edit button reveals that this runs:</font></div><div><b><font color="#a64d79">  mythfrontend --service</font></b></div><div><font color="#a64d79">  </font></div><div>Correct. What is your opinion on how important the --service is at this point? That script is really old if the comments are correct.</div><div><br></div><div>If the --service option is necessary am I correct that the suggestion is to change this line</div><div><br></div><div><b>pidof mythfrontend.real 2>&1 >/dev/null && wmctrl -a "MythTV Frontend" 2>/dev/null && exit 0</b></div><div><br></div><div>To this </div><div><br></div><div><b>pidof mythfrontend.real 2>&1 >/dev/null</b></div><div><b>pidof_retcode=$?</b></div><div><b>if [ $pidof_retcode==0 ]; then</b></div><div><b>  wmctrl -a "MythTV Frontend" 2>/dev/null</b></div><div><b>  wmctrl_retcode=$?</b></div><div><b>else</b></div><div><b>  wmctrl_retcode=1</b></div><div><b>fi</b></div><div><b>if [ pidof_retcode==0 || wmctrl_retcode==0 ]; then</b></div><div><b>  exit 0</b></div><div><b>fi</b></div><div><br></div><div>By the way, <b>pidof mythfrontend.real </b>returns 3524 (the pid) and <b>wmctrl -a "MythTV Frontend"  </b>doesn't return anything at least on a terminal but I think that is normal.</div><div><br></div><div>What I think is going on is that X closes mythfrontend.real but does not close the service.  Then when X opens again and checks if myth is running the service has not had time to get its version of myth running so the pid returns null or 0. This happens so fast and all the services start versions of myth before the pid is valid. One key is that when I do CTRL-ALT-BS I don't always get a new instance, just 80-90% of the time.  This says to me there is a timing component to the problem.  My computer is much faster with the new RAM and my guess is that mostly all the services are busy starting an instance of myth before a pid is established. Perhaps what is needed as the first line of the script is a delay.</div><div><br></div><div>I will test the proposed script changes when I hear from you that I understand it correctly and continue to think it is a good idea. Until then, I am running mythfrontend without the service option. My gut says that is the best solution anyway.   That script is just too old. I don't trust it and doubt that it is necessary any longer.<br></div><div><br></div><div>Allen</div><div><br></div></div></div></div></div></blockquote><div><br></div><div>As I said, eliminating the --service from the autostart edit solved the problem. I have now tried some edits on the script.</div><div><br></div><div>Adding delay to  /usr/share/mythtv/mythfrontend.sh makes it so I only get two instances of mythfrontend instead of one more for every restart. That says to me there are two mechanisms and adding the delay cured one of them. Recall that previously when I did ten restarts I had nine instances of mythfrontend running. I thought this was interesting data so wanted to share it.  It might help in figuring out what is going on as we descend further down the rabbit hole.</div><div><br></div><div>Changing the first line to the suggestion in bold above and keeping the delay (sleep 1) in was the same as keeping the old code.  I would get 2 instances of mythfrontend regardless of how many times I did a reset.  That does not surprise me as the way I read it, it does the same thing as the single line.  The single line relies on the property that the expression is evaluated from left to right and only does the next test if the first one passes.  It is very clever but also very hard to read.  The suggested edit is easier to read but I think does the same thing.</div><div><br></div><div>I have reverted back to not running mythfrontend as a service. I continue to feel this is the best solution.  That script is old and is basically a hack to solve a problem that I would hope is no longer there. But I will find out since I am running without it as a service. <br></div><div><br></div><div>There are two possible paths now.  One is to do nothing and see if myth crashes and needed the autostart. The other is to continue down the rabbit hole and try and solve the problem with the script.  My preference is to continue the search for a solution to the script's issues but I do not feel strongly one way or the other.</div><div><br></div><div>Allen</div><div><br></div><div><br></div></div></div></div>