IPv4 Fremnet Logo
TOOLS, TINKERINGS & CODE

Do you use my code?

MythTV DPMS Preview Disabler · Mar 26, 00:56 by Shannon Wynter

Because the comment in the top of this file is so complete, I’m just going to include the file and let you read it – Download link is at the bottom as usual :)

  1. #!/usr/bin/perl
  2. #############################################################
  3. # MDPD (Myth DPMS Preview Disabler) By Shannon Wynter
  4. # http://fremnet.net/article/254/mythtv-dpms-preview-disabler
  5. #############################################################
  6. # One of the going concerns I have with MythTV is that when
  7. # I walk away from my TV after watching a show (leaving DPMS
  8. # to take care of the power saving) it's frequently left in
  9. # the watch recordings screen.
  10. #
  11. # Because of the Preview available in this screen the hard
  12. # disk never spins down and ticks over quite happily until
  13. # you come back and wake the machine back up.
  14. #
  15. # This simple script checks to see if DPMS has changed from
  16. # the on state to any other state, then asks MythTV what it
  17. # is doing. If MythTV says that it's in Watch Recordings it
  18. # tells MythTV to jump back to Main Menu.
  19. #
  20. # Installation:
  21. # 1) Install required CPAN modules
  22. #       Net::Telnet   (Gentoo: emerge dev-perl/Net-Telnet)
  23. #       X11::Protocol (Gentoo: emerge dev-perl/X11-Protocol)
  24. #
  25. # 2) Make sure you've enabled telnet remote control in your
  26. #    MythFrontend
  27. #
  28. # 3) Run this script
  29. #       I normally pop it into .xinitrc before launching
  30. #       mythfrontend as /path/to/mpdp.pl &
  31. #
  32.  
  33.  
  34. use strict;
  35. use X11::Protocol;
  36. use X11::Protocol::Ext::DPMS;
  37. use Net::Telnet;
  38.  
  39. # I assume you want to be connecting to a local socket
  40. my $host = "localhost";
  41. my $port = 6546;
  42.  
  43. # Configure default Net::Telnet object
  44. my $telnet = new Net::Telnet (
  45. Timeout => 10,
  46. Port    => $port,
  47. Errmode => 'die',
  48. Prompt  => '/#/'
  49. );
  50.  
  51. # Connect to X and initialize the extension to use
  52. my $x = X11::Protocol->new();
  53. $x->init_extension('DPMS');
  54.  
  55. # Storage
  56. my $power_level = '';
  57.  
  58. # Loop forever
  59. while(1) {
  60. # Archive the power level and get the current one
  61. my $old_pl = $power_level;
  62. ($power_level, undef) = $x->DPMSInfo();
  63.  
  64. # See if we've recently switched from DPMSModeOn
  65. if(($old_pl eq 'DPMSModeOn') && ($power_level ne 'DPMSModeOn')) {
  66.   # Connect to mythfrontend
  67.   $telnet->open( $host );
  68.   $telnet->waitfor('/#/i');
  69.  
  70.   # Ask it where we are
  71.   my $line = join('',$telnet->cmd("query location"));
  72.   chomp($line);
  73.  
  74.   # In the PlaybackBox?
  75.   if ($line =~ /PlaybackBox/i) {
  76.   # Leave the PlaybackBox
  77.   $telnet->cmd("jump mainmenu");
  78.   }
  79.   $telnet->close();
  80. }
  81. sleep 60;
  82. }
  83.  
  84. Download this code: mpdp.pl (Downloaded 186 time(s))

Comments

Spam no more - rel=nofollow is active here, spamming my comments will not help your page rank.

  Textile help
---== Copyright Shannon Wynter - All rights reserved - All wrongs avenged ==---
email