mpd-controll in Fvwm-Button - Applet

I´ve written an applet for FvwmButton to controll my mpd:

In the fvwm2rc:

*FvwmButton: (4x2 Frame 0, Colorset 18, Icon player_rew.png Action(Mouse 1) `Exec exec echo -e "previous\\nclose"|nc $mpd_host $mpd_port`, \
							Action(Mouse 3) `Exec exec echo -e "seek -4%\\nclose"|nc $mpd_host $mpd_port`)
#	*FvwmButton: (3x2 Frame 0, Colorset 18, PressColorset 10, Icon player_pause.png PressIcon player_play.png Action(Mouse 1) `Exec exec echo -e "pause\\nclose"|nc $mpd_host $mpd_port` )
*FvwmButton: (3x2 Frame 0, Colorset 18, Id "mpp", Icon player_play.png Action(Mouse 1) `Exec exec /usr/bin/mpc status|grep -q '\[playing\]\|\[paused\]' && /usr/bin/mpc -h $mpd_host -p $mpd_port toggle || /usr/bin/mpc -h $mpd_host -p $mpd_port play`)
*FvwmButton: (3x2 Frame 0, Colorset 18, Icon player_fwd.png Action(Mouse 1) `Exec exec echo -e "next\\nclose"|nc $mpd_host $mpd_port`)
*FvwmButton: (3x2 Frame 0, Colorset 18, Icon player_stop.png Action `Exec exec echo -e "stop\\nclose"|nc $mpd_host $mpd_port`)
*FvwmButton: (4x2 Frame 0, Colorset 18, Icon stock_volume.png Action (Mouse 4) `Exec exec /usr/bin/mpc -h $mpd_host -p $mpd_port volume +5 > /dev/null`, \
							Action (Mouse 5) `Exec exec /usr/bin/mpc -h $mpd_host -p $mpd_port volume -5 > /dev/null`)
*FvwmButton: (22x2, Colorset 18, Frame 0, Swallow FvwmApplet-MpdSongInfo `FvwmScript FvwmApplet-MpdSongInfo 18`)

And the FvwmApplet-MpdSongInfo:

WindowTitle {FvwmApplet-MpdSongInfo}
WindowSize 110 34
Font "Shadow=0 1 SE:xft:Bitstream Dejavu Sans Mono:style=Roman:size=6"

Init
 Begin
  Set $MainColorset=(GetScriptArgument 1)
  If $MainColorset <> {} Then
  Begin
   ChangeColorset 0 $MainColorset
   ChangeColorset 1 $MainColorset
   ChangeColorset 2 $MainColorset
   ChangeColorset 3 $MainColorset
   ChangeColorset 5 $MainColorset
  End
ChangeForeColor 2 {black}
ChangeBackColor 2 {darkgrey}
HideWidget 2
HideWidget 3
HideWidget 4
  Set $song = (GetOutput {exec mpc current} 1 -1)
  Set $pos = (GetOutput {exec mpc} 2 4)
  ChangeTitle  1 $song
End

PeriodicTasks
 Begin 
  If (RemainderOfDiv (GetTime) 1)==0 Then
  Begin
  Set $song = (GetOutput {exec mpc current} 1 -1)
  Set $status = (GetOutput {exec mpc status} 2 1)
  Set $ptime = (GetOutput {exec mpc status} 2 3)
  If $status == { } Then
    Begin
      HideWidget 2
      ShowWidget 3 
      Do {MPD_PLAY_PAUSE player_play.png}
    End
  If $status == [paused] Then
    Begin
      HideWidget 2
      ShowWidget 3
      Do {MPD_PLAY_PAUSE player_play.png}
    End
  If $status == [playing]  Then
    Begin
      HideWidget 3
      ShowWidget 2
      Do {MPD_PLAY_PAUSE player_pause.png}
    End
  ChangeTitle 3 $status
  ChangeTitle  1 $song
  ChangeTitle  5 $ptime
  Set $pos = (GetOutput {exec mpc|sed -e 's/[()%]//g'} 2 4)
  Set $pos = (StrCopy $pos 1 2)
  ChangeValue 2 $pos
  End
End

Widget 1
Property
 Position 0 0
 Size 110 11
 Type ItemDraw
 Flags NoReliefString
 Title {}
Main
 Case message of
  SingleClic :
  Begin
	Do {Exec /usr/bin/x-mpd-client &}
  End
End

Widget 2
Property
 Position 0 14
 Size 110 11
 Type HScrollBar
 Value 0 
 MinValue 0
 MaxValue 100
 Flags NoReliefString
 Title {}
Main
 Case message of
  SingleClic :
  Begin
 	Do {exec /usr/bin/mpc -h $mpd_host -p $mpd_port --quiet seek } (GetValue 2) {%}
  End
End


Widget 3
Property
 Position 0 14
 Size 110 11
 Type ItemDraw
 Flags NoReliefString
 Title {Pause}
End

Widget 5
Property
  Size 110 11
  Position 0 24
  Type ItemDraw
  Flags NoReliefString
  Title {}
End
DestroyFunc MPD_PLAY_PAUSE
AddToFunc MPD_PLAY_PAUSE
+ I SendToModule FvwmShelf ChangeButton "mpp" Icon $0

You need to have installed mpc also an the gnome-icon-theme, which includes this icons (i think it´s the “gnome-icon-theme”)

I´m still looking for a possibility, to scroll the songtitle automatically left and right, to see the full title, if it´s too long for the line.

For /usr/bin/x-mpd-client i made a new group in /etc/alternatives. You can change this to your preferred GUI-Client for mpd.

scientific

But you have this:

Id, "mpp",

Which is incorrect. It should be:

Id "mpp"

– Thomas Adam

I have the right syntax in my config. Made a mistake during editing this posting.

Thx for the correction. I deleted the comma in the text above.

scientific