advanced mixer

Hi! (Sorry for my poor english)

Im new in fvwm but really like it. I tried to write a mixer script but works partly only.
The Widget 1 is not refreshed always.

bindings:

[code]DestroyFunc VolUp
AddToFunc VolUp

  • I PipeRead ‘amixer set $(cat $[FVWM_USERDIR]/tmp/jmix) 1%+ 1>/dev/null
    && FvwmCommand “SendToModule JuuzerMixer SendString 1 1”’

DestroyFunc VolDn
AddToFunc VolDn

  • I PipeRead ‘amixer set $(cat $[FVWM_USERDIR]/tmp/jmix) 1%- 1>/dev/null
    && FvwmCommand “SendToModule JuuzerMixer SendString 1 1”’

DestroyFunc Control
AddToFunc Control

  • I Exec exec FvwmCommand “SendToModule JuuzerMixer SendString 2 1”

Mouse (JuuzerMixer) 4 W A VolUp
Mouse (JuuzerMixer) 5 W A VolDn
Mouse (JuuzerMixer) 1 W A Control
[/code]

the script:

WindowTitle {JuuzerMixer}
WindowSize 300 300

###########
Init
 Begin
  Do {Exec if [ -f $FVWM_USERDIR/tmp/jmix ]; then exit; else echo "Master" > $FVWM_USERDIR/tmp/jmix; fi}
  Set $Controled = (GetOutput {cat $FVWM_USERDIR/tmp/jmix} 1 1)
  SendSignal 1 1
  SendSignal 2 1
 End

#############
Widget 1
Property
 Type ItemDraw
 Size 50 50
 Position 50 50
Main
Case message of

 SingleClic :
 Begin
   ChangeTitle 1 $percent
 End

 1 :
 Begin
  If $Controled == Master Then
  Begin
   Set $percent = (GetOutput {amixer get Master|tail -n1|cut -d[ -f2|cut -d] -f1} 1 -1)
   ChangeTitle 1 $percent
  End
  Else
  Begin
   SendSignal 1 2
  End
 End

 2 :
 Begin
  If $Controled == PCM Then
  Begin
   Set $percent = (GetOutput {amixer get PCM|tail -n1|cut -d[ -f2|cut -d] -f1} 1 -1)
   ChangeTitle 1 $percent
  End
  Else
  Begin
   SendSignal 1 3
  End
 End

 3 :
 Begin
  If $Controled == Line Then
  Begin
   Set $percent = (GetOutput {amixer get Line|tail -n1|cut -d[ -f2|cut -d] -f1} 1 -1)
   ChangeTitle 1 $percent
  End
  Else
  Begin
   SendSignal 1 1
  End
 End

End

##############
Widget 2
Property
 Type ItemDraw
 Size 50 50
 Position 200 200
Main
Case message of

 SingleClic :
 Begin
  ChangeTitle 2 $Controled
 End
 
 1 :
 Begin
  If $Controled == Master Then
  Begin
   Set $Controled = PCM
   ChangeTitle 2 $Controled
   Do {Exec echo "PCM" > $[FVWM_USERDIR]/tmp/jmix}
   SendSignal 1 2
  End
  Else
  Begin
   SendSignal 2 2
  End
 End
  
 2 :
 Begin
  If $Controled == PCM Then
  Begin
   Set $Controled = Line
   ChangeTitle 2 $Controled
   Do {Exec echo "Line" > $[FVWM_USERDIR]/tmp/jmix}
   SendSignal 1 3
  End
  Else
  Begin
   SendSignal 2 3
  End
 End
 
 3 :
 Begin
  If $Controled == Line Then
  Begin
   Set $Controled = Master
   ChangeTitle 2 $Controled
   Do {Exec echo "Master" > $[FVWM_USERDIR]/tmp/jmix}
   SendSignal 1 1
  End
  Else
  Begin
   SendSignal 2 1
  End
 End

End

I don’t know what was the problem works perfectly now.

change the control with left mb (1), volume up/down with scroll (4/5) and mute/unmute with right mb (3)

video: vimeo.com/2453828

styles and bindings:

Style JuuzerMixer Sticky, !Borders, !Title, WindowListSkip, ResizeHintOverride, CirculateSkip

DestroyFunc VolUp
AddToFunc VolUp
+ I PipeRead 'amixer set $(cat $[FVWM_USERDIR]/tmp/jmix) 1%+ 1>/dev/null \
    && FvwmCommand "SendToModule JuuzerMixer SendString 1 1"'

DestroyFunc VolDn
AddToFunc VolDn
+ I PipeRead 'amixer set $(cat $[FVWM_USERDIR]/tmp/jmix) 1%- 1>/dev/null \
    && FvwmCommand "SendToModule JuuzerMixer SendString 1 1"'

DestroyFunc Control
AddToFunc Control
+ I Exec exec FvwmCommand "SendToModule JuuzerMixer SendString 2 1"

DestroyFunc Mute
AddToFunc Mute
+ I PipeRead 'amixer set $(cat $[FVWM_USERDIR]/tmp/jmix) toggle 1>/dev/null \
    && FvwmCommand "SendToModule JuuzerMixer SendString 1 1"'

Mouse (JuuzerMixer) 4 W A VolUp
Mouse (JuuzerMixer) 5 W A VolDn
Mouse (JuuzerMixer) 1 W A Control
Mouse (JuuzerMixer) 3 W A Mute

script

WindowTitle {JuuzerMixer}
WindowSize 50 40
WindowPosition 974 728
Font "Shadow=2"
Colorset 41

###########
Init
 Begin
  Do {Exec if [ -f $FVWM_USERDIR/tmp/jmix ]; then exit; else echo "Master" > $FVWM_USERDIR/tmp/jmix; fi}
  Set $Controled = (GetOutput {cat $FVWM_USERDIR/tmp/jmix} 1 1)
  SendSignal 1 1
  ChangeTitle 2 $Controled
 End

#############
Widget 1
Property
 Type ItemDraw
 Size  25 20
 Position 20 0
Main
Case message of

 SingleClic :
 Begin
   ChangeTitle 1 $percent
 End

 1 :
 Begin
  If $Controled == Master Then
  Begin
   Set $percent = (GetOutput {amixer get Master|tail -n1|cut -d[ -f2|cut -d] -f1} 1 -1)
   ChangeTitle 1 $percent
   Set $state = (GetOutput {amixer get Master|tail -n1|cut -d[ -f4|cut -d] -f1} 1 -1)
   ChangeTitle 3 $state
  End
  Else
  Begin
   SendSignal 1 2
  End
 End

 2 :
 Begin
  If $Controled == PCM Then
  Begin
   Set $percent = (GetOutput {amixer get PCM|tail -n1|cut -d[ -f2|cut -d] -f1} 1 -1)
   ChangeTitle 1 $percent
   Set $state = (GetOutput {amixer get PCM|tail -n1|cut -d[ -f4|cut -d] -f1} 1 -1)
   ChangeTitle 3 $state   
  End
  Else
  Begin
   SendSignal 1 3
  End
 End

 3 :
 Begin
  If $Controled == Line Then
  Begin
   Set $percent = (GetOutput {amixer get Line|tail -n1|cut -d[ -f2|cut -d] -f1} 1 -1)
   ChangeTitle 1 $percent
   Set $state = (GetOutput {amixer get Line|tail -n1|cut -d[ -f4|cut -d] -f1} 1 -1)
   ChangeTitle 3 $state
  End
  Else
  Begin
   SendSignal 1 1
  End
 End

End

##############
Widget 2
Property
 Type ItemDraw
 Size 50 20
 Position 0 20
Main
Case message of

 SingleClic :
 Begin
  ChangeTitle 2 $Controled
 End
  1 :
 Begin
  If $Controled == Master Then
  Begin
   Set $Controled = PCM
   ChangeTitle 2 $Controled
   Do {Exec echo "PCM" > $[FVWM_USERDIR]/tmp/jmix}
   SendSignal 1 2
  End
  Else
  Begin
   SendSignal 2 2
  End
 End
  
 2 :
 Begin
  If $Controled == PCM Then
  Begin
   Set $Controled = Line
   ChangeTitle 2 $Controled
   Do {Exec echo "Line" > $[FVWM_USERDIR]/tmp/jmix}
   SendSignal 1 3
  End
  Else
  Begin
   SendSignal 2 3
  End
 End
 
 3 :
 Begin
  If $Controled == Line Then
  Begin
   Set $Controled = Master
   ChangeTitle 2 $Controled
   Do {Exec echo "Master" > $[FVWM_USERDIR]/tmp/jmix}
   SendSignal 1 1
  End
  Else
  Begin
   SendSignal 2 1
  End
 End

End

###############
Widget 3
Property
 Type ItemDraw
 Size 20 20
 Position 0 0
Main
Case message of

 SingleClic :
 Begin
  ChangeTitle 3 $state
 End

End

This is incorrect. You’re in the middle of a piperead, and yet you’re using FvwmCommand to send results back to FVWM? No. Just echo them back – that’s why piperead exists in the first place.

As an example:

+ I PipeRead 'amixer set $(< $[FVWM_USERDIR]/tmp/jmix) toggle 1>/dev/null \
    && echo SendToModule JuuzerMixer SendString 1 1'

– Thomas Adam