MythTV TIP – Power Button
Every once and a while mythfrontend gets stuck for one reason or another. Now when this happens I just ssh into the mythbox and restart gdm. This almost always brings thing back up and running. While I do usually have my laptop about its still a bit of a pain to break out of TV mode and start sshing in. Seeing this gave me the idea to put my power button to good use but I felt the script was overly complicated given how well the gdm restart worked. But since restarting gdm requires root privileges and thus a password to run I was stymied. Until I learned about the sudoers file that is. Editing this file lets you gives users the ability to sudo certain commands without a password – it actually does way more than that but its not relevant to the post. Now if you are not careful editing sudoers can scrap your system so precede with caution. Now on to the good stuff. To edit sudoers use the following command.
sudo visudo
This will apply some basic sanity checking before you save the file; making it every so slightly more difficult to slag your system. Anyway add the following line. (replace user_name with the user mythfrontend runs under)
user_name ALL=NOPASSWD: /etc/init.d/gdm restart
Make sure to put this at the end of the file otherwise rules may override it. That took me about half an hour and countless fiddle logout/login cycles.
Now add something like the following your your lirc file.
#Power Button
begin
remote = remote_name
prog = irexec
button = Power
config = sudo /etc/init.d/gdm restart
end
Now after you logout and log back in your power button should restart gdm allowing you to ‘fix’ any frontend hanging issues from your remote.
*Note – This tip has no warranty or support. If it deletes your files or blows up your computer don’t come crying to me.