%
% anyremote configuration file for Listen management (Server-mode)
% prerequisites: amixer/pactl utility
%

% STATUS stable
% XTEST no
% SOUND mixer
% ENV no
% DEF_PLAYER   
% ALL_IN_ONE 

GuiAppName=Listen
GuiAppBinary=listen
GuiAppRun=echo 'P=`pgrep listen`; if [ "x$P" == "x" ]; then echo NOK; else echo OK; fi'|bash -f -s
GuiAppIcon=listen.png
GuiAppType=Application
GuiAppProtocols=Server
GuiAppDesc=Listen is an audio player written in Python

[Protocol]=Server

(Init)=\
	Include($(CfgDir)/Utils/aliases-server.cfg);\
	Macro(SETUP_DEFAULT_MIXER);\
	Make(var,player_name,by_value,Listen);\
	Include($(CfgDir)/Utils/aliases-server-player.cfg);

(Connect)=Make(mode,listen);

[Mode]=listen : default_player

% (EnterMode) by Utils/aliases-server-player.cfg

LISTEN_SETTITLE=\
	Make(var,listen_album,P=`pgrep listen`; if [ "x$P" != "x" ]; then qdbus org.gnome.Listen /org/gnome/listen org.gnome.Listen.get_album; else echo ""; fi);\
	Make(var,listen_song,P=`pgrep listen`; if [ "x$P" != "x" ]; then qdbus org.gnome.Listen /org/gnome/listen current_playing; else echo ""; fi);\
	ExecAndSet(title,P=`pgrep listen`; if [ "x$P" != "x" ]; then echo "$(listen_album) - $(listen_song)"; else echo ""; fi);\
	ExecAndSet(status,P=`pgrep listen`; if [ "x$P" != "x" ]; then qdbus org.gnome.Listen /org/gnome/listen org.gnome.Listen.get_artist; else echo ""; fi);

% Volume control and 0-9,*,# assignments by Utils/aliases-server-player.cfg

PLAY =Exec(qdbus org.gnome.Listen /org/gnome/listen play_pause);Macro(LISTEN_SETTITLE);Timer(LISTEN_SETTITLE,5,0);
RWD  =Exec(qdbus org.gnome.Listen /org/gnome/listen rewind);
FF   =Exec(qdbus org.gnome.Listen /org/gnome/listen forward);
PREV =Exec(qdbus org.gnome.Listen /org/gnome/listen previous);Macro(LISTEN_SETTITLE);
STOP =Exec(qdbus org.gnome.Listen /org/gnome/listen play_pause);Timer(LISTEN_SETTITLE,cancel)
NEXT =Exec(qdbus org.gnome.Listen /org/gnome/listen next);Macro(LISTEN_SETTITLE);
PAUSE=Exec(qdbus org.gnome.Listen /org/gnome/listen play_pause);Timer(LISTEN_SETTITLE,cancel)

RUN_IF_NEED=Exec(P=`pgrep listen`; if [ "x$P" = "x" ]; then listen 2> /dev/null & fi);
RUN_OR_QUIT=Exec(P=`pgrep listen`; if [ "x$P" = "x" ]; then listen 2> /dev/null & else qdbus org.gnome.Listen /org/gnome/listen quit; fi);
QUIT=Exec(qdbus org.gnome.Listen /org/gnome/listen quit);Timer(LISTEN_SETTITLE,cancel);

[ModeEnd]

[End]
