[mythtvnz] MythTV integration

Mike Dilger mythtvnz@lists.linuxnut.co.nz
Mon, 14 Aug 2006 10:15:33 +1200


This is a multi-part message in MIME format.
--------------000804010501080009030101
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit


I've just setup a nice MythTV integration that allows me to use external
applications like yammi for MP3s, etc, and still do it all from the
remote control.  (I never tried knoppmyth so I don't know what they've
done and can't compare at this stage).

MythTV is great, for what it does.

However, when it comes to playing MP3s, or browsing the web, why oh why
use plugins?  The music plugin is OK, but it's not as great as some
other programs out there... for instance, I'm a big fan of yammi.   And
the web plugin is abysmal... I'd much rather just pop up firefox.

But I don't want to yank out the keyboard and mouse to do it.  I still
want to control my box via remote control (except for web browsing).

And I've got these great remote buttons that have been unused:  "TV",
"Music", "Video", Go", "Radio", etc.  If I press "Music" on my remote, I
want to be taken to yammi, regardless of what program I'm in the middle
of.   If I press TV, I want to be taken to MythTV...  If I press Video,
I want to be taken to xine.  If I press Go, I want firefox to take over.

So what I did was modify the irexec program that comes with lirc.  I
call the new tool "cinemalaunch".  This small tweak changes several things
(1) the new program is always listening, even while another program has
taken control
(2) when you select TV or Video or whatever you want, it kills the
currently running process(group) and starts up what you asked for
(3) it runs a minimal window manager.

Then I set my .xinitrc to just run cinemalaunch.  Cinemalaunch will run
the window manager (I'm using matchstick) as a subprocess, so that
cinemalaunch can exit (power button) and that will log me out.

The source code is attached.  I also attached my (getting kinda long
now) lircrc.  The top section shows how it integrates cinemalaunch.  
BTW: In order to get yammi to use the remote, I use xmms as it's plugin.

Mike


--------------000804010501080009030101
Content-Type: text/plain;
 name="lircrc"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="lircrc"

# ----------------------------------------------------------
# irexec -- the main application chooser, by button
# ----------------------------------------------------------

  begin
    prog = cinemalaunch
    button = TV
    repeat = 0
    config = /usr/bin/mythfrontend
  end

  begin
    prog = cinemalaunch
    button = Music
    repeat = 0
    config = /usr/bin/yammi --nofork --geometry 1920x1200
  end

  begin
    prog = cinemalaunch
    button = Go
    repeat = 0
    config = /usr/bin/firefox -height 1200 -width 1920
  end

  begin
    prog = cinemalaunch
    button = Power
    repeat = 0
    config = quit
  end

# ----------------------------------------------------------
# XMMS
# ----------------------------------------------------------

  # Volume
  # ------

  begin
    prog = xmms
    button = Vol+
    config = vol_up 2
    repeat = 1
  end

  begin
    prog = xmms
    button = Vol-
    config = vol_down 2
    repeat = 1
  end

  begin
    prog = xmms
    button = Mute
    config = mute
  end

  # Action (xmms)
  # ------

  begin
    prog = xmms
    button = Play
    repeat = 3
    config = play
  end

  begin
    prog = xmms
    button = Stop
    repeat = 3
    config = stop
  end

  begin
    prog = xmms
    button = Pause
    repeat = 3
    config = pause
  end

  begin
    prog = xmms
    button = Forward
    repeat = 0
    config = FWD 5
  end

  begin
    prog = xmms
    button = Rewind
    repeat = 0
    config = BWD 5
  end

  begin
    prog = xmms
    button = Replay/SkipBackward
    repeat = 3
    config = prev
  end

  begin
    prog = xmms
    button = SkipForward
    repeat = 3
    config = next
  end

  # MENU (xmms)
  # ----

  begin
    prog = xmms
    button = Menu/i
    config = osd
    repeat =6 
  end

#  begin
#    prog = xmms
#    button = Power
#    repeat = 3
#    config = quit
#  end

  begin
    prog = xmms
    button = Back/Exit
    config = quit
    repeat = 3
  end

  begin
    prog = xmms
    button = Up
    config = vo_fullscreen
    repeat = 3
  end


# ----------------------------------------------------------
# MPLAYER
# ----------------------------------------------------------

  # Volume
  # ------

  begin
    prog = mplayer
    button = Vol+
    config = volume 1
    repeat = 1
  end

  begin
    prog = mplayer
    button = Vol-
    config = volume -1
    repeat = 1
  end

  begin
    prog = mplayer
    button = Mute
    config = mute
  end

  # Action (mplayer)
  # ------

  begin
    prog = mplayer
    button = Play
    config = seek +1
      # Skip ahead a minute if playing
      # If paused, resume playing
    repeat = 3
  end

  begin
    prog = mplayer
    button = Stop
    config = quit 0
    repeat = 3
  end

  begin
    prog = mplayer
    button = Pause
    config = pause
    repeat = 3
  end

  begin
    prog = mplayer
    button = Forward
    repeat = 0
    config = seek +10
  end

  begin
    prog = mplayer
    button = Rewind
    repeat = 0
    config = seek -10
  end

  begin
    prog = mplayer
    button = Replay/SkipBackward
    repeat = 3
    config = pt_step -1
  end

  begin
    prog = mplayer
    button = SkipForward
    repeat = 3
    config = pt_step 1
  end

  # MENU (mplayer)
  # ----

  begin
    prog = mplayer
    button = Menu/i
    config = osd
    repeat =6 
  end

#  begin
#    prog = mplayer
#    button = Power
#    config = quit
#    repeat = 3
#  end

  begin
    prog = mplayer
    button = Back/Exit
    config = quit
    repeat = 3
  end

  begin
    prog = mplayer
    button = Up
    config = vo_fullscreen
    repeat = 3
  end

# ----------------------------------------------------------
# VLC
# ----------------------------------------------------------

  begin
    prog = vlc
    button = Pause
    config = key-play
  end

  begin
    prog = vlc
    button = Pause
    config = key-pause
  end

  begin
    prog = vlc
    button = Stop
    config = key-stop
  end

  begin
    prog = vlc
    button = Back/Exit
    config = key-quit
  end

  begin
    prog = vlc
    button = Ch+
    config = key-next
    repeat = 0
  end

 begin
    prog = vlc
    button = Ch-
    config = key-prev
    repeat = 0
  end

  begin
    prog = vlc
    button = Up
    config = key-fullscreen
  end

  begin
    prog = vlc
    button = Red
    config = key-slower
  end

  begin
    prog = vlc
    button = Green
    config = key-faster
  end

  begin
    prog = vlc
    button = Left
    config = key-jump-3sec
    repeat = 1
  end

  begin
    prog = vlc
    button = Right
    config = key-jump+3sec
    repeat = 1
  end

  begin
    prog = vlc
    button = Replay
    config = key-jump-1min
  end

  begin
    prog = vlc
    button = Skip
    config = key-jump+1min
  end

  # Audio
  # -----

  begin
    prog = vlc
    button = Vol-
    config = key-vol-down
    repeat = 1
  end

  begin
    prog = vlc
    button = Vol+
    config = key-vol-up
    repeat = 1
  end

  begin
    prog = vlc
    button = Blue
    config = key-audio-track
  end

  begin
    prog = vlc
    button = Mute
    config = key-vol-mute
  end

# ----------------------------------------------------------
# MythTV
# ----------------------------------------------------------

  # Main
  # ----
  
#  begin
#    prog = mythtv
#    button = Power
#    config = Esc
#  end

  begin
    prog = mythtv
    button = Back/Exit
    config = Esc
  end

  begin
    prog = mythtv
    button = Ok
    #config = Space
    config = Enter
  end

  begin
    prog = mythtv
    button = Menu/i
    config = I
        # OSD
    repeat = 6
  end

  # Volume
  # ------
  
  begin
    prog = mythtv
    button = Vol+
    config = F11
    repeat = 1
  end

  begin
    prog = mythtv
    button = Vol-
    config = F10
    repeat = 1
  end

  begin
    prog = mythtv
    button = Mute
    config = F9
        # mute
  end

  # Action
  # ------

  begin
    prog = mythtv
    button = Stop
    config = T
  end

  begin
    prog = mythtv
    button = Forward
    repeat = 0
    config = >
  end

  begin
    prog = mythtv
    button = Rewind
    repeat = 0
    config = <
  end

  begin
    prog = mythtv
    button = Play
    repeat = 3
    config = Enter
  end

  begin
    prog = mythtv
    button = Pause
    repeat = 3
    config = P
  end

  begin
    prog = mythtv
    button = SkipForward
    repeat = 3
    config = PgDown
        # Default 10 minutes
  end

  begin
    prog = mythtv
    button = Replay/SkipBackward
    repeat = 3
    config = PgUp
        # Default 10 minutes
  end

  # Directions
  # ----------

  begin
    prog = mythtv
    button = Up
    repeat = 3
    config = Up
    #config = Key W CurrentWindow
  end

  begin
    prog = mythtv
    button = Down
    repeat = 3
    config = Down
    #config = Key S Current Window
  end

  begin
    prog = mythtv
    button = Left
    repeat = 3
    config = Left
    #config = Key A CurrentWindow
  end

  begin
    prog = mythtv
    button = Right
    repeat = 3
    config = Right
    #config = Key D CurrentWindow
  end

  # Channels & Numbers
  # ------------------

  begin
    prog = mythtv
    button = Ch+
    repeat = 3
    config = Up
  end

  begin
    prog = mythtv
    button = Ch-
    repeat = 3
    config = Down
  end

  begin
    prog = mythtv
    button = 0
    config = 0
    #config = Key KP_0 CurrentWindow
    repeat = 3
  end

  begin
    prog = mythtv
    button = 1
    config = 1
    repeat = 3
  end

  begin
    prog = mythtv
    button = 2
    config = 2
    repeat = 3
  end

  begin
    prog = mythtv
    button = 3
    config = 3
    repeat = 3
  end

  begin
    prog = mythtv
    button = 4
    config = 4
    repeat = 3
  end

  begin
    prog = mythtv
    button = 5
    config = 5
    repeat = 3
  end

  begin
    prog = mythtv
    button = 6
    config = 6
    repeat = 3
  end

  begin
    prog = mythtv
    button = 7
    config = 7
    repeat = 3
  end

  begin
    prog = mythtv
    button = 8
    config = 8
    repeat = 3
  end

  begin
    prog = mythtv
    button = 9
    config = 9
    repeat = 3
  end

  # Other
  # -----


  begin
    prog = mythtv
    button = Record
    repeat = 3
    config = R
  end

  begin
    prog = mythtv
    button = Red
    repeat = 3
    config = D
        # Delete
  end

  begin
    prog = mythtv
    button = Guide
    repeat = 3
    config = M
        # On Screen Display
  end

  begin
    prog = mythtv
    button = Blue
    repeat = 3
    config = O
      # Display EPG while in live TV,
      # View selected show while in EPG
  end

#  begin
#    prog = mythtv
#    button = Go
#    repeat = 3
# Swap the PiP windows
#    config = N
#  end

#  begin
#    prog = mythtv
#    button = Pictures
# Change focus for PiP (ch channel in the other window)
#    config = B
#  end

# Change display aspect ratio
# begin
# prog = mythtv
# button = FULL
# repeat = 3
# config = W
# end

#  begin
#    prog = mythtv
#    button = YELLOW
#    repeat = 3
#    config = Q
#     # Seek to previous commercial cut point
#  end

#  begin
#    prog = mythtv
#    button = BLUE
#    repeat = 3
#    config = Z
#      # Seek to next commercial cut point
#  end

# ----------------------------------------------------------
# XINE
# ----------------------------------------------------------

##
# xine key bindings.
# Automatically generated by xine-ui version 0.99.5.
##

# start playback
begin
	button = Play
	prog   = xine
	repeat = 0
	config = Play
end

# playback pause toggle
begin
	button = Pause
	prog   = xine
	repeat = 0
	config = Pause
end

# stop playback
begin
	button = Stop
	prog   = xine
	repeat = 0
	config = Stop
end

# take a snapshot
begin
	button = Record 
	prog   = xine
	repeat = 0
	config = Snapshot
end

# eject the current medium
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = Eject
#end

# select and play next MRL in the playlist
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = NextMrl
#end

# select and play previous MRL in the playlist
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = PriorMrl
#end

# loop mode toggle
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = ToggleLoopMode
#end

# stop playback after played stream
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = PlaylistStop
#end

# scan playlist to grab stream infos
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = ScanPlaylistInfo
#end

# add a mediamark from current playback
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = AddMediamark
#end

## edit selected mediamark
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = MediamarkEditor
#end

# set position to -60 seconds in current stream
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = SeekRelative-60
#end

# set position to +60 seconds in current stream
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = SeekRelative+60
#end

# set position to -30 seconds in current stream
#begin
#	button = Rewind
#	prog   = xine
#	repeat = 0
#	config = SeekRelative-30
#end

# set position to +30 seconds in current stream
#begin
#	button = Forward
#	prog   = xine
#	repeat = 0
#	config = SeekRelative+30
#end

# set position to -15 seconds in current stream
begin
	button = Rewind
	prog   = xine
	repeat = 0
	config = SeekRelative-15
end

# set position to +15 seconds in current stream
begin
	button = Forward
	prog   = xine
	repeat = 0
	config = SeekRelative+15
end

# set position to -7 seconds in current stream
#begin
#	button = Rewind
#	prog   = xine
#	repeat = 2
#	config = SeekRelative-7
#end

# set position to +7 seconds in current stream
#begin
#	button = Forward
#	prog   = xine
#	repeat = 2
#	config = SeekRelative+7
#end

# set position to beginning of current stream
#begin
#	button = xxxxxx
#	prog   = xine
#	repeat = 0
#	config = SetPosition0%
#end

# set position to 10% of current stream
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = SetPosition10%
#end

# set position to 20% of current stream
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = SetPosition20%
#end

# set position to 30% of current stream
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = SetPosition30%
#end

# set position to 40% of current stream
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = SetPosition40%
#end

# set position to 50% of current stream
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = SetPosition50%
#end

# set position to 60% of current stream
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = SetPosition60%
#end

# set position to 70% of current stream
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = SetPosition70%
#end

# set position to 80% of current stream
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = SetPosition80%
#end

# set position to 90% of current stream
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = SetPosition90%
#end

# increment playback speed
begin
	button = Pound
	prog   = xine
	repeat = 0
	config = SpeedFaster
end

# decrement playback speed
begin
	button = Asterisk
	prog   = xine
	repeat = 0
	config = SpeedSlower
end

# reset playback speed
begin
	button = Red
	prog   = xine
	repeat = 0
	config = SpeedReset
end

# increment audio volume
begin
	button = Vol+
	prog   = xine
	repeat = 0
	config = Volume+
end

# decrement audio volume
begin
	button = Vol-
	prog   = xine
	repeat = 0
	config = Volume-
end

# increment amplification level
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = Amp+
#end

# decrement amplification level
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = Amp-
#end

# reset amplification to default value
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = ResetAmp
#end

# audio muting toggle
begin
	button = Mute
	prog   = xine
	repeat = 0
	config = Mute
end

# select next audio channel
#begin
#	button = xxxxxx
#	prog   = xine
#	repeat = 0
#	config = AudioChannelNext
#end

# select previous audio channel
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = AudioChannelPrior
#end

# visibility toggle of audio post effect window
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = APProcessShow
#end

# toggle post effect usage
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = APProcessEnable
#end

# select next sub picture (subtitle) channel
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = SpuNext
#end

# select previous sub picture (subtitle) channel
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = SpuPrior
#end

# interlaced mode toggle
begin
	button = Blue
	prog   = xine
	repeat = 0
	config = ToggleInterleave
end

# cycle aspect ratio values
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = ToggleAspectRatio
#end

# reduce the output window size by factor 1.2
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = WindowReduce
#end

# enlarge the output window size by factor 1.2
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = WindowEnlarge
#end

# set video output window to 50%
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = Window50
#end

# set video output window to 100%
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = Window100
#end

# set video output window to 200%
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = Window200
#end

# zoom in
begin
	button = Ch+
	prog   = xine
	repeat = 0
	config = ZoomIn
end

# zoom out
begin
	button = Ch-
	prog   = xine
	repeat = 0
	config = ZoomOut
end

# zoom in horizontally
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = ZoomInX
#end

# zoom out horizontally
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = ZoomOutX
#end

# zoom in vertically
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = ZoomInY
#end

# zoom out vertically
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = ZoomOutY
#end

# reset zooming
begin
	button = Prev.Ch
	prog   = xine
	repeat = 0
	config = ZoomReset
end

# resize output window to stream size
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = Zoom1:1
#end

# fullscreen toggle
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = ToggleFullscreen
#end

# Xinerama fullscreen toggle
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = ToggleXineramaFullscr
#end

# jump to Title Menu
begin
	button = Menu/i
	prog   = xine
	repeat = 0
	config = Title Menu
end

# jump to Root Menu
begin
	button = Guide
	prog   = xine
	repeat = 0
	config = RootMenu
end

# jump to Subpicture Menu
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = SubpictureMenu
#end

# jump to Audio Menu
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = AudioMenu
#end

# jump to Angle Menu
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = AngleMenu
#end

# jump to Part Menu
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = PartMenu
#end

# menu navigate up
begin
	button = Up
	prog   = xine
	repeat = 0
	config = EventUp
end

# menu navigate down
begin
	button = Down
	prog   = xine
	repeat = 0
	config = EventDown
end

# menu navigate left
begin
	button = Left
	prog   = xine
	repeat = 0
	config = EventLeft
end

# menu navigate right
begin
	button = Right
	prog   = xine
	repeat = 0
	config = EventRight
end

# menu select
begin
	button = OK
	prog   = xine
	repeat = 0
	config = EventSelect
end

# jump to next chapter
begin
	button = SkipForward
	prog   = xine
	repeat = 0
	config = EventNext
end

# jump to previous chapter
begin
	button = Replay/SkipBackward
	prog   = xine
	repeat = 0
	config = EventPrior
end

# select next angle
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = EventAngleNext
#end

# select previous angle
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = EventAnglePrior
#end

# visibility toggle of help window
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = HelpShow
#end

# visibility toggle of video post effect window
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = VPProcessShow
#end

# toggle post effect usage
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = VPProcessEnable
#end

# visibility toggle of output window
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = ToggleWindowVisibility
#end

# bordered window toggle of output window
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = ToggleWindowBorder
#end

# visibility toggle of UI windows
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = ToggleVisibility
#end

# visibility toggle of control window
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = ControlShow
#end

# visibility toggle of mrl browser window
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = MrlBrowser
#end

# visibility toggle of playlist editor window
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = PlaylistEditor
#end

# visibility toggle of the setup window
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = SetupShow
#end

# visibility toggle of the event sender window
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = EventSenderShow
#end

# visibility toggle of analog TV window
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = TVAnalogShow
#end

# visibility toggle of log viewer
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = ViewlogShow
#end

# visibility toggle of stream info window
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = StreamInfosShow
#end

# display stream information using OSD
begin
	button = Yellow
	prog   = xine
	repeat = 0
	config = OSDStreamInfos
end

# show OSD menu
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = OSDMenu
#end

# enter key binding editor
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = KeyBindingEditor
#end

# open file selector
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = FileSelector
#end

# select a subtitle file
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = SubSelector
#end

# download a skin from the skin server
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = SkinDownload
#end

# display MRL/Ident toggle
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = MrlIdentToggle
#end

# grab pointer toggle
begin
	button = Green
	prog   = xine
	repeat = 0
	config = GrabPointer
end

# enter the number 0
begin
	button = 0
	prog   = xine
	repeat = 0
	config = Number0
end

# enter the number 1
begin
	button = 1
	prog   = xine
	repeat = 0
	config = Number1
end

# enter the number 2
begin
	button = 2
	prog   = xine
	repeat = 0
	config = Number2
end

# enter the number 3
begin
	button = 3
	prog   = xine
	repeat = 0
	config = Number3
end

# enter the number 4
begin
	button = 4
	prog   = xine
	repeat = 0
	config = Number4
end

# enter the number 5
begin
	button = 5
	prog   = xine
	repeat = 0
	config = Number5
end

# enter the number 6
begin
	button = 6
	prog   = xine
	repeat = 0
	config = Number6
end

# enter the number 7
begin
	button = 7
	prog   = xine
	repeat = 0
	config = Number7
end

# enter the number 8
begin
	button = 8
	prog   = xine
	repeat = 0
	config = Number8
end

# enter the number 9
begin
	button = 9
	prog   = xine
	repeat = 0
	config = Number9
end

# add 10 to the next entered number
#begin
#	button = xxxxxx
#	prog   = xine
#	repeat = 0
#	config = Number10add
#end

# set position in current stream to numeric percentage
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = SetPosition%
#end

# set position forward by numeric argument in current stream
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = SeekRelative+
#end

# set position back by numeric argument in current stream
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = SeekRelative-
#end

# change audio video syncing (delay video)
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = AudioVideoDecay+
#end

# change audio video syncing (delay audio)
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = AudioVideoDecay-
#end

# reset audio video syncing offset
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = AudioVideoDecayReset
#end

# change subtitle syncing (delay video)
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = SpuVideoDecay+
#end

# change subtitle syncing (delay subtitles)
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = SpuVideoDecay-
#end

# reset subtitle syncing offset
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = SpuVideoDecayReset
#end

# toggle TV modes (on the DXR3)
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = ToggleTVmode
#end

# switch Monitor to DPMS standby mode
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = DPMSStandby
#end

# increase hue by 10
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = HueControl+
#end

# decrease hue by 10
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = HueControl-
#end

# increase saturation by 10
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = SaturationControl+
#end

# decrease saturation by 10
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = SaturationControl-
#end

# increase brightness by 10
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = BrightnessControl+
#end

# decrease brightness by 10
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = BrightnessControl-
#end

# increase contrast by 10
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = ContrastControl+
#end

# decrease contrast by 10
#begin
#	button = xxxxx
#	prog   = xine
#	repeat = 0
#	config = ContrastControl-
#end

# quit the program
begin
	button = Back/Exit
	prog   = xine
	repeat = 0
	config = Quit
end

##
# End of xine key bindings.
##

--------------000804010501080009030101
Content-Type: text/x-csrc;
 name="cinemalaunch.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="cinemalaunch.c"

/* cinemalaunch */
/* Branched from irexec */
/* gcc -o cinemalaunch cinemalaunch.c -llirc_client */

#include <errno.h>
#include <unistd.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <lirc/lirc_client.h>

void doquit();
void startwm();
void startimage();

#define WM "/usr/bin/matchbox-window-manager"

char *progname;
void makechildargs(char *);
char *childargs[10];  /* up to 10 strings */
char *minusc;

int main(int argc, char *argv[])
{
  struct lirc_config *config;
  int sock;
  int flags;
  pid_t child = 0;
  int status;
  int wpid;

  startwm();

  minusc = strdup("-c");  /* fixed string for args later */

  progname=argv[0];
  if(argc>2)
    {
      fprintf(stderr,"Usage: %s <config file>\n",progname);
      exit(EXIT_FAILURE);
    }
  sock=lirc_init("cinemalaunch",1);
  if (sock==-1) exit(EXIT_FAILURE);

  if(lirc_readconfig(argc==2 ? argv[1]:NULL,&config,NULL)==0)
    {
      char *code;
      char *command;
      int ret;
      int going=1;

      while (going && (lirc_nextcode(&code)==0))
        {
          if(code==NULL) continue;
          while((ret=lirc_code2char(config,code,&command))==0 &&
                command!=NULL)
            {
              if (strcmp(command,"quit")==0) {
                going=0;
                break;
              }

              /* Close any current running child */
              if (child!=0) {

                //
                //#ifdef DEBUG
                //printf("%s: We have a running child already... \"%d\"\n",progname,child);
                //#endif
                //status=wpid=0;
                //wpid = waitpid(child,&status,WNOHANG);

                ///* If still running... */
                //if ( (wpid==0) || !WIFEXITED(status) )  {

                /* Kill the running child */
#ifdef DEBUG
                printf("%s: Terminating child group \"%d\"\n",progname,child);
#endif
                killpg(getpgid(child),SIGTERM);
                int loop=10;
                while (loop) {
                  status=wpid=0;
                  wpid = waitpid(child,&status,WNOHANG);
                  if ( (wpid!=0) && WIFEXITED(status) ) break;
                  usleep(150);  /* 0.15 seconds */
                  loop--;
                }
                if (!loop) {
#ifdef DEBUG
                  printf("%s: Killing child \"%d\"\n",progname,child);
#endif
                  killpg(getpgid(child),SIGKILL);
                  while (1) {  /* forever if hung */
                    status=wpid=0;
                    wpid = waitpid(child,&status,WNOHANG);
                    if ( (wpid!=0) && WIFEXITED(status) ) break;
                    usleep(150);  /* 0.15 seconds */
                  }
                }
              }

              /* Close any currently running xmms (seems to escape */
              /* the process group of yammi) */
              system("killall -s 1 xmms");
              usleep(80);
              system("killall -s 9 xmms");

              makechildargs(command);

#ifdef DEBUG
              printf("%s: Execing command \"%s\"\n",progname,command);
#endif

              if ( (child=vfork()) ==0 ) {
                execv(childargs[0],childargs);
                /* system(c); */
              }

              /* Set process group of the child seperate from ours */
              /* So we can kill that whole group */
              setpgid(child,0);
            }
          free(code);
          if(ret==-1) break;

          /* Set non-blocking */
          flags=fcntl(sock,F_GETFL,0);
          if(flags!=-1)
            {
              fcntl(sock,F_SETFL,flags|O_NONBLOCK);
            }

          /* Read and throw away any accumulated lirc
           * messages */
          while ((lirc_nextcode(&code)==0) && (code!=NULL)) ;

          /* Set to blocking again */
          flags=fcntl(sock,F_GETFL,0);
          if(flags!=-1)
            {
              fcntl(sock,F_SETFL,flags&(~O_NONBLOCK));
            }

        }
      lirc_freeconfig(config);
    }

  lirc_deinit();
  exit(EXIT_SUCCESS);
}

void makechildargs(char *c)
{
  char *token=NULL;
  int count=0; 
  static char *memory=NULL;

  if (memory!=NULL) free(memory);
  memory=strdup(c);  

  /* First arg for the shell
     childargs[0]=minusc;
     count++;
  */

  token = strtok(memory," \t");
  if (token!=NULL) {
    childargs[count++]=token;
    token = strtok(NULL," \t");
  }
  childargs[count]=NULL;
}


void startwm()
{
  if (vfork()==0) {
    execl(WM,WM,NULL);
  }
}

void startimage()
{
  /* this doesn't work -- wm? takes over root? */
  if (vfork()==0) {
    execl("/usr/bin/xloadimage","/usr/bin/xloadimage","-onroot",
          "-fullscreen","-quiet","/usr/local/share/sunspot.jpg",NULL);
  }
}

--------------000804010501080009030101--