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.
Programatically exit mythfrontend?
Moderator: Forum Moderators
Re: Programatically exit mythfrontend?
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
$
Re: Programatically exit mythfrontend?
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.
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.