1% 2% anyremote configuration file for MPD management (Server-mode) 3% 4% prerequisites: mpc client, mpd must be started already with playlist prepared 5% 6 7% STATUS nonstable 8% TODO who must start mpd and prepare playlist? 9% XTEST no 10% SOUND app 11% ENV no 12% ALL_IN_ONE 13% TODO make stable 14 15GuiAppName=MPD 16GuiAppBinary=mpc 17GuiAppRun=P=`ps -ef|grep mpd|grep -v grep|grep -v anyremote|grep -v nedit|grep -v mpd.cfg`; if [ "x$P" = "x" ]; then echo NOK; else echo OK; fi 18GuiAppType=Application 19GuiAppProtocols=Server 20GuiAppDesc=Music Player Daemon (MPD) allows remote access for playing music. Mpd should be started and playlist should be prepared before runing anyRemote. 21 22[Protocol]=Server 23 24(Init)=\ 25 Include($(CfgDir)/Utils/aliases-server.cfg);\ 26 Macro(CheckMPC);\ 27 Macro(CheckMPD);\ 28 Macro(CheckPL);\ 29 Make(var,home,echo $HOME);\ 30 Make(var,player_name,by_value,MPD);\ 31 Include($(CfgDir)/Utils/aliases-server-player.cfg); 32 33(Connect)=Make(mode,mpd); 34 35Cancel=\ 36 Make(exit); 37 38[Mode]=mpd_general 39 40CheckMPC=\ 41 Exec(P=`which mpc 2> /dev/null|grep mpc|grep -v no|wc -l|tr -d " "`; \ 42 if [ "x$P" = "x0" ]; then $(CfgDir)/Utils/message.sh "ERROR: mpc client is not installed"; fi); 43 44CheckMPD=\ 45 Exec(P=`ps -ef|grep mpd|grep -v grep|grep -v mpd.cfg|wc -l|tr -d " "`; \ 46 if [ "x$P" = "x0" ]; then $(CfgDir)/Utils/message.sh "ERROR: mpd is not run"; fi); 47 48CheckPL=\ 49 Exec(P=`mpc playlist 2> /dev/null|wc -l|tr -d " "`; \ 50 if [ "x$P" = "x0" ]; then $(CfgDir)/Utils/message.sh "ERROR: mpd playlist is empty"; fi); 51 52MPD_SETTILE=\ 53 ExecAndSet(title,sleep 1;mpc|head -n1|while read name;do echo $name;done) 54 55[ModeEnd] 56 57[Mode]=mpd : mpd_general,default_player 58 59(EnterMode)=\ 60 Macro(SETUP_DEFAULT_POWER_MANAGEMENT);\ 61 Macro(RUN_IF_NEED);\ 62 Macro(SETUP_DEFAULT_PLAYER);\ 63 Make(var,mpd_volume,by_value,-1);\ 64 Macro(APP_MENU); 65 66(ExitMode) =Timer(MPD_SETTILE,cancel) 67 68APP_MENU=\ 69 Set(menu,replace,Playlist,Toggle Shuffle,Toggle Repeat,PowerMgmt);\ 70 Macro(ALLIN1MENU); 71 72Back=\ 73 Set(text,close);\ 74 Macro(APP_MENU); 75 76Toggle Shuffle=\ 77 Exec(mpc shuffle); 78 79Toggle Repeat=\ 80 Exec(mpc repeat); 81 82Playlist=\ 83 Make(mode,mpd_playlist); 84 85% Override 861=Exec(mpc volume -5) 872=Make(var,mpd_volume,\ 88 if [ "x$(mpd_volume)" = "x-1" ]; then \ 89 mpc volume|tr -s " "|cut -f 2 -d " "|sed "s/%//";mpc volume 0 > /dev/null; \ 90 else \ 91 mpc volume $(mpd_volume) > /dev/null;echo "-1"; \ 92 fi); 933=Exec(mpc volume +5) 94 95PLAY=\ 96 Exec(mpc play);\ 97 Macro(MPD_SETTILE);\ 98 Timer(MPD_SETTILE,$(UpdateTimeout),0); 99 100RWD=\ 101 Exec(mpc seek -00:00:05); 102 103FF=\ 104 Exec(mpc seek +00:00:05); 105 106PREV=\ 107 Exec(mpc prev);\ 108 Macro(MPD_SETTILE); 109 110NEXT=\ 111 Exec(mpc next);\ 112 Macro(MPD_SETTILE); 113 114STOP=\ 115 Exec(mpc stop);\ 116 Timer(MPD_SETTILE,cancel); 117 118PAUSE=\ 119 Exec(mpc toggle); 120 121RUN_IF_NEED=\ 122 Make(none); 123 124RUN_OR_QUIT=\ 125 Make(none); 126 127QUIT=\ 128 Exec(mpd --kill); 129 130[ModeEnd] 131 132[Mode]=mpd_playlist 133 134(EnterMode)=\ 135 Timer(MPD_SETTILE,cancel);\ 136 Set(list,font,medium);\ 137 ExecAndSet(list,replace,Playlist,mpc playlist|tr -d ','|tr -s ' '|cut -f 2,3,4,5,6,7 -d " "|\ 138 sed "s/%20/ /g;s/$/,/;s/,/\r/g;s/(/-/g;s/)/-/g;s/$/,/");\ 139 Set(menu,replace,Choose); 140 141(ExitMode)=\ 142 Set(list,close);\ 143 Macro(MPD_SETTILE);\ 144 Timer(MPD_SETTILE,$(UpdateTimeout),0); 145 146Back($$)=\ 147 Make(mode,mpd); 148 149Choose($$)=\ 150 Exec(mpc play $(Index)); 151 152Push($$)=\ 153 Macro(Choose($$)); 154 155[ModeEnd] 156 157[End] 158