Programatically exit mythfrontend?

For discussion related to MythTV which doesn't belong in another forum.

Moderator: Forum Moderators

Post Reply
wmorrison
Senior
Posts: 165
Joined: Sat Dec 01, 2018 12:05 am
United States of America

Programatically exit mythfrontend?

Post by wmorrison »

Is there any way an external script can cause mythfrontend (if running) to exit in the normal way, asking the user "Do you really want to exit MythTV?" with a yes/no choice?

I have an IR sensor for my power button (SIMEREC PCS-1) which works great to turn the system on, but I'd like to make pressing it when the system is already on simply exit mythfrontend gracefully and let MythTV handle whether to actually shut down or not depending on whether it is busy or not.
User avatar
paulh
Developer
Posts: 909
Joined: Thu Feb 06, 2014 6:09 pm
Great Britain

Re: Programatically exit mythfrontend?

Post by paulh »

One way would be to use the frontend network interface to send the relevant key presses.

Code: Select all

$ nc localhost 6546
MythFrontend Network Control
Type 'help' for usage information
---------------------------------
# jump mainmenu
OK
# key escape
OK
# quit
$
wmorrison
Senior
Posts: 165
Joined: Sat Dec 01, 2018 12:05 am
United States of America

Re: Programatically exit mythfrontend?

Post by wmorrison »

Here's what I found out, trying the Frontend service.

https://www.mythtv.org/wiki/Frontend_Service

First, the examples shown are GET requests, which always returned 404. But they work with a POST request (if the frontend is running. If not, they always return 404.)

SendAction with Action=EXITPROMPT works as I expected only when on the main menu. On a submenu, it simply goes up a menu level. On an actual MythTV screen (not a pure menu) it does nothing.

I tried going to the main menu with SendAction, but could't make that work. But I mapped a key for a jump point to the main menu, then used SendKey, and that worked. So that plus another EXITPROMPT would kind of do it.

However, I realized this isn't actually what I want. If you are busy in a screen (watching a recording, scheduling recordings, etc.) jumping to the main menu cancels what you are doing. What I am really looking for is a way to prompt the user in case the power button is pressed accidentally, without "losing your spot" if you answer "No" at the prompt.

So I think instead of trying to get a Myth-themed exit prompt, I'll just use something like zenity, and if the user answers yes, only then shutdown the frontend.
Post Reply