Alternating FvwmButtons

So I’m trying to use FvwmButtons to control my music using mpd and mpc. Right now I’m just experimenting with it, but I would like my play button to alternate between a pause button and a play button each time it’s pressed. Here’s what the button’s config looks like now:

*MyButtons: (3x1, Icon /home/mike/play.xpm, \ Action(Mouse1) "Exec exec mpc play" )

Does anyone know how to / if its possible to do this? Thanks in advance for your help.

[color=red]Edited by theBlackDragon:
–> Moved from Basic questions[/color]

What you’re looking for is saving the state of your button as described in this thread: http://fvwm.lair.be/viewtopic.php?t=510.

Well I just atemped copying what was in that thread and changing some lines so that it does what I want and here’s what I got: [code]DestroyFunc TogglePlay
AddToFunc TogglePlay
+I ThisWindow (State 1) Play
+I TestRc (NoMatch) Pause

DestroyFunc Play
AddToFunc Play

  • I Exec exec mpc play
  • I Icon /home/mike/pause.xpm
  • I State 1 False

DestroyFunc Pause
AddToFunc Pause

  • I Exec exec mpc pause
  • I Icon /home/mike/play.xpm
  • I State 1 True[/code]

And here is what I have for the button:

*MyButtons: (3x1, Icon /home/mike/play.xpm, \ Action(Mouse1) "TogglePlay" )

Obviously this is wrong because it doesn’t work. And my music doesn’t play nor pause. Can anyone tell me what I’ve done wrong? Thanks in advance for your help.

Add a space after the “Action”, so that it becomes:

Action (Mouse1) TogglePlay

No need for quotes.

– Thomas Adam

well I changed that part to: *MyButtons: (3x1, Icon /home/mike/play.xpm, \ Action (Mouse1) TogglePlay )
And it still does nothing.

It looks OK to me. I don’t know, then. If FVWM logs to ~/.xsession-errors, check it.

– Thomas Adam

Well I still haven’t gotten this to work, but I have found the mpc has a funtion to use the command mpc toggle to toggle playing or pause. But I still can’t get this working. Right now this is what I’ve got:

[code]DestroyFunc TogglePlay
AddToFunc TogglePlay
+I ThisWindow (State 1) Play
+I TestRc (NoMatch) Pause

DestroyFunc Play
AddToFunc Play

  • I Exec exec mpc toggle
  • I Icon /home/mike/pause.xpm
  • I State 1 False

DestroyFunc Pause
AddToFunc Pause

  • I Exec exec mpc toggle
  • I Icon /home/mike/play.xpm
  • I State 1 True

[/code]

When I click the button to play or pause on my FvwmButtons dock, nothing happens at all. So I think there is something wrong with this part here: DestroyFunc TogglePlay AddToFunc TogglePlay +I ThisWindow (State 1) Play +I TestRc (NoMatch) Pause

Anyone have any ideas?

Do you get any output in ~/.xsession-errors , also can you specify an Icon like that, without passing it an explicit reference to the window it should be assigned to (eg Style $0 or something similar)?

You could of course always use Hun’s FvwmMpd-player which does basically the same thing :slight_smile:

well there is not output to ~/.xession-errors. but if you can specify an icon like that, wouldn’t the button still function if everything else was right?

Go back to basics – using FvwmConsole, type out your “Play” and “Pause” functions into it, and call them from there. If they work from inside thaty, then that’s a start, although they probably won’t. Just as a thought, where you have:

 + I Exec exec mpc pause

try:

+ I Exec exec "mpc pause"

The quoting ought not to make a difference in this instance, but you never know.

– Thomas Adam