Tkmythremote

From MythTV Official Wiki
Revision as of 22:58, 17 June 2013 by Rayslinky (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Important.png Note: The correct title of this article is tkmythremote. It appears incorrectly here due to technical restrictions.


Author Tony Lill
Description A simple Tk-based remote control for MythTV that uses the control socket to send keys to mythfrontend.
Supports



tkmythremote is a simple Tk-based remote control for MythTV that uses the Frontend control socket to send keys to mythfrontend.

Usage

tkmythremote frontendhost

The Script

Script.png tkmythremote

#! /usr/bin/wish
#
# I dare you to make a simpler GUI!
#
# To customize images, create a .xbm file and include the file contents in the
# appropriate image data definition, below.
#
# Usage: tkmythremote frontendhost

set image_Esc "
#define esc_width 21
#define esc_height 21
static unsigned char esc_bits[] = {
 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x1f, 0x00,
 0x80, 0x3f, 0x00, 0xc0, 0x7f, 0x00, 0xe0, 0xff, 0x00, 0xf0, 0xff, 0x01,
 0xf8, 0xff, 0x03, 0xfc, 0xff, 0x07, 0xfe, 0xff, 0x0f, 0x00, 0x00, 0x00,
 0x00, 0x00, 0x00, 0xfe, 0xff, 0x0f, 0xfe, 0xff, 0x0f, 0xfe, 0xff, 0x0f,
 0xfe, 0xff, 0x0f, 0xfe, 0xff, 0x0f, 0xfe, 0xff, 0x0f, 0x00, 0x00, 0x00,
 0x00, 0x00, 0x00 } ;
"
set image_Play "
#define p_width 21
#define p_height 21
static unsigned char p_bits[] = {
 0x00, 0x00, 0x00, 0xee, 0x04, 0x00, 0xee, 0x0c, 0x00, 0xee, 0x1c, 0x00,
 0xee, 0x3c, 0x00, 0xee, 0x7c, 0x00, 0xee, 0xfc, 0x00, 0xee, 0xfc, 0x01,
 0xee, 0xfc, 0x03, 0xee, 0xfc, 0x07, 0xee, 0xfc, 0x0f, 0xee, 0xfc, 0x07,
 0xee, 0xfc, 0x03, 0xee, 0xfc, 0x01, 0xee, 0xfc, 0x00, 0xee, 0x7c, 0x00,
 0xee, 0x3c, 0x00, 0xee, 0x1c, 0x00, 0xee, 0x0c, 0x00, 0xee, 0x04, 0x00,
 0x00, 0x00, 0x00 } ;
"
set image_Enter "
#define ent_width 21
#define ent_height 21
static unsigned char ent_bits[] = {
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x03, 0x00, 0x80, 0x03,
 0x00, 0x80, 0x03, 0x00, 0x80, 0x03, 0x00, 0x80, 0x03, 0x00, 0x80, 0x03,
 0x00, 0x80, 0x03, 0x00, 0x80, 0x03, 0x00, 0x80, 0x03, 0x20, 0x80, 0x03,
 0x30, 0x80, 0x03, 0x38, 0x80, 0x03, 0xfc, 0xff, 0x03, 0xfe, 0xff, 0x03,
 0xfc, 0xff, 0x03, 0x38, 0x00, 0x00, 0x30, 0x00, 0x00, 0x20, 0x00, 0x00,
 0x00, 0x00, 0x00 } ;
"
set image_Up "
#define noname_width 21
#define noname_height 21
static char noname_bits[] = {
 0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x0e,0x00,0x00,0x1f,0x00,0x80,0x3f,0x00,
 0xc0,0x7f,0x00,0xe0,0xff,0x00,0xf0,0xff,0x01,0xf8,0xff,0x03,0xfc,0xff,0x07,
 0xfe,0xff,0x0f,0xfe,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 0x00,0x00,0x00};
"
set image_Down "
#define noname_width 21
#define noname_height 21
static char noname_bits[] = {
 0x01,0x00,0x00,0x01,0x00,0x00,0x01,0x00,0x00,0x01,0x00,0x00,0x01,0x00,0x00,
 0xfd,0xff,0x1f,0xfd,0xff,0x1f,0xf9,0xff,0x0f,0xf1,0xff,0x07,0xe1,0xff,0x03,
 0xc1,0xff,0x01,0x81,0xff,0x00,0x01,0x7f,0x00,0x01,0x3e,0x00,0x01,0x1c,0x00,
 0x01,0x08,0x00,0x01,0x00,0x00,0x01,0x00,0x00,0x01,0x00,0x00,0x01,0x00,0x00,
 0x01,0x00,0x00};
"
set image_Left "
#define noname_width 21
#define noname_height 21
static char noname_bits[] = {
 0x00,0x00,0x00,0x00,0xc0,0x00,0x00,0xe0,0x00,0x00,0xf0,0x00,0x00,0xf8,0x00,
 0x00,0xfc,0x00,0x00,0xfe,0x00,0x00,0xff,0x00,0x80,0xff,0x00,0xc0,0xff,0x00,
 0xe0,0xff,0x00,0xc0,0xff,0x00,0x80,0xff,0x00,0x00,0xff,0x00,0x00,0xfe,0x00,
 0x00,0xfc,0x00,0x00,0xf8,0x00,0x00,0xf0,0x00,0x00,0xe0,0x00,0x00,0xc0,0x00,
 0x00,0x00,0x00};
"
set image_Right "
#define right_width 21
#define right_height 21
static unsigned char right_bits[] = {
 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0xe0, 0x00, 0x00, 0xe0, 0x01, 0x00,
 0xe0, 0x03, 0x00, 0xe0, 0x07, 0x00, 0xe0, 0x0f, 0x00, 0xe0, 0x1f, 0x00,
 0xe0, 0x3f, 0x00, 0xe0, 0x7f, 0x00, 0xe0, 0xff, 0x00, 0xe0, 0x7f, 0x00,
 0xe0, 0x3f, 0x00, 0xe0, 0x1f, 0x00, 0xe0, 0x0f, 0x00, 0xe0, 0x07, 0x00,
 0xe0, 0x03, 0x00, 0xe0, 0x01, 0x00, 0xe0, 0x00, 0x00, 0x60, 0x00, 0x00,
 0x00, 0x00, 0x00 } ;
"
set image_Home "
#define noname_width 21
#define noname_height 21
static char noname_bits[] = {
 0x00,0x00,0x00,0x00,0x04,0x08,0x00,0x06,0x0c,0x00,0x07,0x0e,0x80,0x07,0x0f,
 0xc0,0x87,0x0f,0xe0,0xc7,0x0f,0xf0,0xe7,0x0f,0xf8,0xf7,0x0f,0xfc,0xff,0x0f,
 0xfe,0xff,0x0f,0xfc,0xff,0x0f,0xf8,0xf7,0x0f,0xf0,0xe7,0x0f,0xe0,0xc7,0x0f,
 0xc0,0x87,0x0f,0x80,0x07,0x0f,0x00,0x07,0x0e,0x00,0x06,0x0c,0x00,0x04,0x08,
 0x00,0x00,0x00};
"
set image_End "
#define dright_width 21
#define dright_height 21
static unsigned char dright_bits[] = {
 0x00, 0x00, 0x00, 0x02, 0x04, 0x00, 0x06, 0x0c, 0x00, 0x0e, 0x1c, 0x00,
 0x1e, 0x3c, 0x00, 0x3e, 0x7c, 0x00, 0x7e, 0xfc, 0x00, 0xfe, 0xfc, 0x01,
 0xfe, 0xfd, 0x03, 0xfe, 0xff, 0x07, 0xfe, 0xff, 0x0f, 0xfe, 0xff, 0x07,
 0xfe, 0xfd, 0x03, 0xfe, 0xfc, 0x01, 0x7e, 0xfc, 0x00, 0x3e, 0x7c, 0x00,
 0x1e, 0x3c, 0x00, 0x0e, 0x1c, 0x00, 0x06, 0x0c, 0x00, 0x02, 0x04, 0x00,
 0x00, 0x00, 0x00 } ;
"
set image_PageUp "
#define noname_width 21
#define noname_height 21
static char noname_bits[] = {
 0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x0e,0x00,0x00,0x1f,0x00,
 0x80,0x3f,0x00,0xc0,0x7f,0x00,0xe0,0xff,0x00,0xf0,0xff,0x01,0xf8,0xff,0x03,
 0xfc,0xff,0x07,0xfe,0xff,0x0f,0x00,0x0e,0x00,0x00,0x1f,0x00,0x80,0x3f,0x00,
 0xc0,0x7f,0x00,0xe0,0xff,0x00,0xf0,0xff,0x01,0xf8,0xff,0x03,0xfc,0xff,0x07,
 0xfe,0xff,0x0f};
"
set image_PageDown "
#define noname_width 21
#define noname_height 21
static char noname_bits[] = {
 0x01,0x00,0x00,0xfd,0xff,0x1f,0xf9,0xff,0x0f,0xf1,0xff,0x07,0xe1,0xff,0x03,
 0xc1,0xff,0x01,0x81,0xff,0x00,0x01,0x7f,0x00,0x01,0x3e,0x00,0x01,0x1c,0x00,
 0xfd,0xff,0x1f,0xf9,0xff,0x0f,0xf1,0xff,0x07,0xe1,0xff,0x03,0xc1,0xff,0x01,
 0x81,0xff,0x00,0x01,0x7f,0x00,0x01,0x3e,0x00,0x01,0x1c,0x00,0x01,0x08,0x00,
 0x01,0x00,0x00};
"
set image_Quit "
#define q_width 21
#define q_height 21
static unsigned char q_bits[] = {
 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x80, 0x3f, 0x00, 0xc0, 0x60, 0x00,
 0x60, 0xc0, 0x00, 0x30, 0x80, 0x01, 0x18, 0x00, 0x03, 0x18, 0x00, 0x03,
 0x18, 0x00, 0x03, 0x18, 0x00, 0x03, 0x18, 0x00, 0x03, 0x18, 0x00, 0x03,
 0x18, 0x00, 0x03, 0x18, 0x00, 0x03, 0x30, 0x78, 0x01, 0x60, 0xc0, 0x01,
 0xc0, 0xc0, 0x01, 0x80, 0x7f, 0x03, 0x00, 0x3f, 0x0e, 0x00, 0x00, 0x00,
 0x00, 0x00, 0x00 } ;
"
set image_Delete "
#define d_width 21
#define d_height 21
static unsigned char d_bits[] = {
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0xf8, 0x7f, 0x00,
 0x18, 0xc0, 0x00, 0x18, 0x80, 0x01, 0x18, 0x00, 0x03, 0x18, 0x00, 0x03,
 0x18, 0x00, 0x03, 0x18, 0x00, 0x03, 0x18, 0x00, 0x03, 0x18, 0x00, 0x03,
 0x18, 0x00, 0x03, 0x18, 0x00, 0x03, 0x18, 0x00, 0x01, 0x18, 0x80, 0x01,
 0x18, 0xc0, 0x00, 0xf8, 0x7f, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0x00, 0x00,
 0x00, 0x00, 0x00 } ;
"
set image_Menu "
#define m_width 21
#define m_height 21
static unsigned char m_bits[] = {
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x1c, 0x00, 0x07,
 0x3c, 0x80, 0x07, 0x6c, 0xc0, 0x06, 0xcc, 0x60, 0x06, 0x8c, 0x31, 0x06,
 0x0c, 0x1b, 0x06, 0x0c, 0x0e, 0x06, 0x0c, 0x04, 0x06, 0x0c, 0x00, 0x06,
 0x0c, 0x00, 0x06, 0x0c, 0x00, 0x06, 0x0c, 0x00, 0x06, 0x0c, 0x00, 0x06,
 0x0c, 0x00, 0x06, 0x0c, 0x00, 0x06, 0x0c, 0x00, 0x06, 0x00, 0x00, 0x00,
 0x00, 0x00, 0x00 } ;
"
set image_Info "
#define i_width 21
#define i_height 21
static unsigned char i_bits[] = {
 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x06, 0x00,
 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00,
 0x00, 0x07, 0x00, 0x80, 0x07, 0x00, 0x00, 0x06, 0x00, 0x00, 0x06, 0x00,
 0x00, 0x06, 0x00, 0x00, 0x06, 0x00, 0x00, 0x06, 0x00, 0x00, 0x06, 0x00,
 0x00, 0x06, 0x00, 0x00, 0x0f, 0x00, 0xc0, 0x3f, 0x00, 0x00, 0x00, 0x00,
 0x00, 0x00, 0x00 } ;
"
if { [ llength $argv ] != 1 } {
    puts "Usage: $argv0 host\n"
    exit
}

set host [lindex $argv 0]
wm title . $host

set f [socket $host 6546]
fconfigure $f -blocking 0 -buffering none

proc push {key} {
    global f
    puts $f "key $key\n"
    read $f
}

# Create all the buttons
button .esc     -image [image create bitmap -data $image_Esc] \
                -command "push escape"
button .play    -image [image create bitmap -data $image_Play] \
                -command "push p"
button .ent     -image [image create bitmap -data $image_Enter] \
                -command "push enter"
button .up      -image [image create bitmap -data $image_Up] \
                -command "push up"
button .down    -image [image create bitmap -data $image_Down] \
                -command "push down"
button .left    -image [image create bitmap -data $image_Left] \
                -command "push left"
button .right   -image [image create bitmap -data $image_Right] \
                -command "push right"
button .backcom -image [image create bitmap -data $image_Home] \
                -command "push home"
button .forwcom -image [image create bitmap -data $image_End] \
                -command "push end"
button .pgup    -image [image create bitmap -data $image_PageUp] \
                -command "push pageup"
button .pgdown  -image [image create bitmap -data $image_PageDown] \
                -command "push pagedown"
button .quit    -image [image create bitmap -data $image_Quit] \
                -command "exit"
button .delete  -image [image create bitmap -data $image_Delete] \
                -command "push d"
button .menu    -image [image create bitmap -data $image_Menu] \
                -command "push m"
button .info    -image [image create bitmap -data $image_Info] \
                -command "push i"
bind . <Control-Key-Up> {push "pageup"}
bind . <Control-Key-Down> {push "pagedown"}
bind . <Key> {push [string tolower "%K"]}
label .host -text "MythTV frontend:\n$host"

# Arrange the buttons in  grid
# esc   ent  up   i   quit
# pgup  left p right  menu
# pgd   bc  down fc    del
grid .esc     -in . -row 1 -column 1
grid .ent     -in . -row 1 -column 2
grid .up      -in . -row 1 -column 3
grid .info    -in . -row 1 -column 4
grid .quit    -in . -row 1 -column 5
grid .pgup    -in . -row 2 -column 1
grid .left    -in . -row 2 -column 2
grid .play    -in . -row 2 -column 3
grid .right   -in . -row 2 -column 4
grid .pgdown  -in . -row 3 -column 1
grid .backcom -in . -row 3 -column 2
grid .down    -in . -row 3 -column 3
grid .forwcom -in . -row 3 -column 4
grid .delete  -in . -row 2 -column 5
grid .menu    -in . -row 3 -column 5
grid .host    -in . -row 4 -columnspan 5

Customizing

To customize images, create an X BitMap (.xbm) image (using your favorite image editor, such as The GIMP) and include the file contents in the appropriate image data definition within the script. If you prefer to keep your images separate, change the image definitions:

set image_Esc "
#define esc_width 21
#define esc_height 21
static unsigned char esc_bits[] = {
 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x1f, 0x00,
 0x80, 0x3f, 0x00, 0xc0, 0x7f, 0x00, 0xe0, 0xff, 0x00, 0xf0, 0xff, 0x01,
 0xf8, 0xff, 0x03, 0xfc, 0xff, 0x07, 0xfe, 0xff, 0x0f, 0x00, 0x00, 0x00,
 0x00, 0x00, 0x00, 0xfe, 0xff, 0x0f, 0xfe, 0xff, 0x0f, 0xfe, 0xff, 0x0f,
 0xfe, 0xff, 0x0f, 0xfe, 0xff, 0x0f, 0xfe, 0xff, 0x0f, 0x00, 0x00, 0x00,
 0x00, 0x00, 0x00 } ;
"

to refer to a file:

set image_Esc "./escape.xbm"

Then change the button definitions to use -file instead of -data:

button .esc     -image [image create bitmap -file $image_Esc] \
                -command "push escape"

The existing images are all 21x21 pixels.