# Support for 'Music On Console' music player
# Written by:  Maciej Delmanowski <harnir@post.pl>
# Modded  by:  rysiul  <tuxator@o2.pl>
# Modifications, debugging and improvments by Dominique Michel 2008-2013
# <dominique_free@users.sourceforge.net>

# Initialisations, shared functions
Include components/functions/Music

# First button {{{1
# Player controls and prefs
# mouse 1 Menu /Player {{{2
AddToFunc Music-GUI
+ I All (mocp) Close
+ I TestRc (NoMatch) All (MOC*) Close
+ I TestRc (NoMatch) AT mocp mocp
#+ I TestRc (NoMatch) None (mocp) AT mocp mocp

# Player-generator (All)
AddToFunc Player-generator
+ I DestroyMenu recreate /Player
+ I AddToMenu /Player '%22x22/fvwm-crystal/audio-x-generic.png%$[gt.Recreate the Playlists]' Music-RecreatePlaylist
+ I AddToMenu /Player '%22x22/fvwm-crystal/audio-x-generic.png%$[gt.Music player]' Popup /Preferences/MusicPlayer
+ I AddToMenu /Player "" Nop
+ I AddToMenu /Player '$[gt.Start QJackCtl]' Exec exec qjackctl
+ I AddToMenu /Player "" Nop
+ I AddToMenu /Player '$[gt.Start Music On Console]' AT mocp mocp
+ I AddToMenu /Player '$[gt.Stop player]' Exec exec killall -9 mocp
+ I AddToMenu /Player '$[gt.Show/Hide player]' Music-GUI

# mouse 2 Music-GUI : allready here {{{2
# mouse 3 Music-QJackGUI : in Music
# mouse 4 Mixer-Volume-Up
# mouse 5 Mixer-Volume-Down
# are in components/Mixer

# Second button {{{1
# Player controls and main vol
# mouse 1 Menu /Playlist-button {{{1
AddToFunc FuncFvwmMenuAudioDirectory
+ I PipeRead 'case \"$0\" in \
	"$[infostore.AudioPlaylists]"*) myexec="mocp --sync --append";; \
	"$[infostore.UserManagedAudioPlaylists]"*) myexec="mocp --sync --append";; \
    esac; \
    test -f \"$0\"/.icontitle.png && mytitle=\"$0\"/.icontitle.png; \
    test -f \"$0\"/.media.png && mypng=\"$0\"/.media.png; \
    fvwm-menu-directory --icon-title "${mytitle:-22x22/categories/directory.png}" \
    --icon-file "${mypng:-22x22/categories/Audio.png}" \
    --func="FuncFvwmMenuAudioDirectory" \
    --exec-file "^${myexec}" --dir \"$0\" \
    --exec-t="-"'

AddToFunc Music-ClearPlaylist
+ I Exec exec mocp --sync --clear

AddToFunc Playlist-generator-button
+ I DestroyMenu recreate /Playlist-button
+ I AddToMenu /Playlist-button '$[gt.Remove playlist]' Popup /Music/RemovePlaylist
+ I AddToMenu /Playlist-button '$[gt.Playlist copy]' Popup /Music/CopyPlaylist
+ I AddToMenu /Playlist-button '$[gt.Clear playlist]' Music-ClearPlaylist
+ I AddToMenu /Playlist-button '$[gt.Load playlist]' Popup /Music/LoadPlaylist

AddToMenu /Playlist-button
+ DynamicPopupAction Function Playlist-generator-button

# mouse 2 Menu /Playback {{{2
AddToFunc Music-Next
+ I Exec exec mocp --sync --next

AddToFunc Music-Prev
+ I Exec exec mocp --sync --previous

AddToFunc Music-Stop
+ I Exec exec mocp --sync --stop

AddToFunc Music-Play
+ I Exec exec mocp --sync --play

AddToFunc Music-Pause
+ I Exec exec mocp --sync --pause

AddToFunc Music-PlayPause
+ I Exec exec mocp --sync --toggle-pause

AddToFunc Playback-generator
+ I DestroyMenu recreate /Playback
+ I AddToMenu /Playback '$[gt.Next]' Music-Next
+ I AddToMenu /Playback '$[gt.Prev]' Music-Prev
+ I AddToMenu /Playback "" Nop
+ I AddToMenu /Playback '$[gt.Stop playback]' Music-Stop
+ I AddToMenu /Playback '$[gt.Play]' Music-Play
+ I AddToMenu /Playback '$[gt.Pause]' Music-Pause
+ I AddToMenu /Playback '$[gt.Play/Pause]' Music-PlayPause

# mouse 3 Menu /Mixer : in components/Mixer {{{2
# mouse 4 Music-Next : allready here
# mouse 4 Music-Prev : allready here

# Main functions and menus {{{1
AddToFunc Music-generator
+ I DestroyMenu recreate /Music
+ I AddToMenu /Music '$[gt.Load playlist]'	Popup /Music/LoadPlaylist
+ I AddToMenu /Music '$[gt.Clear playlist]'	Music-ClearPlaylist
+ I AddToMenu /Music '$[gt.Remove playlist]'	Popup /Music/RemovePlaylist
+ I AddToMenu /Playlist-button '$[gt.Playlist copy]' Popup /Music/CopyPlaylist
+ I AddToMenu /Music "" Nop
+ I AddToMenu /Music '$[gt.Stop playback]'	Music-Stop
+ I AddToMenu /Music '$[gt.Play/Pause]'		Music-PlayPause
+ I AddToMenu /Music "" Nop
+ I AddToMenu /Music '$[gt.Music player]'	Popup /Preferences/MusicPlayer

# Fake button functions {{{1
# Menu /Music/Volume (TODO)
AddToMenu /Music/Volume
+ "" Nop
# Music-Speed-Up
AddToFunc Music-Speed-Up
+ I Nop
# Music-Speed-Down
AddToFunc Music-Speed-Down
+ I Nop
# Menu /Speed
AddToMenu /Speed
+ "" Nop
# Music-Seek-+
# Music-Seek--
AddToFunc Music-Seek
+ I Nop

# vim:ft=fvwm
