Guayadeque: Server mode

Criminal
2011-10-14
2012-12-10
  • Criminal
    Criminal
    2011-10-14

    Hi there,

    I took amarok.cfg and modified it to work with guayadeque.
    Volume management affects amixer directly, not guayadeque.

    Since I've got no place to upload, I'm pasting the code here.

    %
    % anyremote configuration file for guayadeque management. (Server-mode)
    %
    % made by Fabian Frank (onlinezeug@gmx.net)
    % ---- based on amarok.cfg (initial version) by Carlos Sanchez
    % working for my purpose ;)
    % not tested when anyremote compiled without dbus support
    GuiAppName=Guayadeque
    GuiAppBinary=guayadeque
    GuiAppVersion=
    GuiAppRun=echo 'A=`pgrep guayadeque`; if [ "x$A" == "x" ]; then echo NOK; else echo OK; fi'|bash -f -s
    GuiAppIcon=amarok.png
    GuiAppType=Application
    GuiAppProtocols=Server
    GuiAppDesc=Guayadeque Music Player
    [Protocol]=Server
    (Init)=Include($(CfgDir)/Utils/aliases-server.cfg);\
        Exec(echo 'P=`which dbus-send|grep dbus-send|grep -v no|wc -l|tr -d " "`;if [ "x$P" == "x1" ]; then true; else $(CfgDir)/Utils/message.sh "ERROR: dbus-send is not found"; fi'|bash -f -s);\
        Exec(echo 'P=`which qdbus|grep qdbus|grep -v no|wc -l|tr -d " "`; if [ "x$P" == "x1" ]; then true; else $(CfgDir)/Utils/message.sh "ERROR: qdbus is not found"; fi'|bash -f -s);\
    (Connect)=Set(parameter,debug,on);\
        Make(mode,guayadeque);
    (Disconnect)=Timer(GUAYADEQUE_TITLE,cancel);
    GUAYADEQUE_HELP =Set(text,replace,Help, 1 Vol-\n 2 Mute\n 3 Vol+\n 4 Rewind\n 5 Play\n 6 FF\n 7 Prew\n 8 Stop\n 9 Next\n ** Help\n 0 Pause\n # toggle Fullscreen);
    GUAYADEQUE_TITLE=Make(var,art,qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.GetMetadata|grep artist:|sed 's/artist://');\
        Make(var,tit,qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.GetMetadata|grep title:|sed 's/title://');\
        Set(title,$(art) - $(tit));\
        Timer(TitleTimer, reset);
    
    GUAYADEQUE_SET_VOL=Make(var,vol,amixer sget Master|grep "Mono: Playback"|sed 's/  Mono: Playback*.\([0-9]*\).*/\1/g');\
        Make(var,vol,expr `expr $(vol) \* 100` \/ 39);\
        Set(volume,$(vol));
        
    GUAYADEQUE_CHECK_MUTE=Make(var,guaya_mute,amixer sget Master|grep "Mono: Playback"|cut -f8 -d" "|sed 's/\[\([a-z]*\).*/\1/g');\
        Make(var,guaya_mute,echo 'if [ "x$(guaya_mute)" == "xon" ]; then echo ""; else echo "MUTE"; fi'|bash -f -s);\
        Set(status,$(guaya_mute));
    TitleTimer=Macro(GUAYADEQUE_TITLE);
    MuteTimer=Macro(GUAYADEQUE_CHECK_MUTE);
    [Mode]=guayadeque
    (EnterMode)=Exec(echo 'A=`pgrep guayadeque`; if [ "x$A" == "x" ]; then guayadeque 2> /dev/null; fi'|bash -f -s);\
        Set(skin,default,ticker,volume);\
        Timer(TitleTimer,5,0);\
        Set(fullscreen,on);\
        Set(icons,Guayadeque,1,vol_down,2,mute,3,vol_up,4,rewind,5,play,6,forward,7,prev,8,stop,9,next,*,refresh,0,pause,#,fullscreen);\
        Set(font,small);\
        Make(var,guaya_dbus,echo 'if [ "x$(Dbus)" == "xyes" ]; then echo guayadeque_dbus; else echo guayadeque_nodbus; fi'|bash -f -s);\
        Make(mode,$(guaya_dbus));
    [ModeEnd]
    %
    % Will be used if compiled with dbus support
    %
    [Mode]=guayadeque_dbus
    (EnterMode)=Dbus(connect,guaya,org.mpris.guayadeque,/Player,org.freedesktop.MediaPlayer);\
        Dbus(connect,guaya2,org.mpris.guayadeque,/,org.freedesktop.MediaPlayer);\
        Macro(GUAYADEQUE_TITLE);\
        Macro(GUAYADEQUE_SET_VOL);\
        Macro(GETPOS);\
        Macro(ALLIN1MENU);\
    GETPOS=Dbus(get,guaya,PositionGet,int,guaya_pos);
    Cancel=Dbus(set,guaya2,Quit);Exit;
    Back=Set(text,close);\
        Macro(ALLIN1MENU);
    1=Emulate(key,AudioLowerVolume);\
        Macro(GUAYADEQUE_SET_VOL);\
        Macro(GUAYADEQUE_SET_VOL);
    2=Emulate(key,AudioMute);\
        Timer(MuteTimer,1,1);
    3=Emulate(key,AudioRaiseVolume);\
        Macro(GUAYADEQUE_SET_VOL);\
        Macro(GUAYADEQUE_SET_VOL);
    4=Macro(GETPOS);\
        Make(var,guaya_pos,expr $(guaya_pos) - 10000);\
        Dbus(set,guaya,PositionSet,int,$(guaya_pos));
    
    5=Dbus(set,guaya,Play);Macro(GUAYADEQUE_TITLE);
    6=Macro(GETPOS);\
        Make(var,guaya_pos,expr $(guaya_pos) + 10000);\
        Dbus(set,guaya,PositionSet,int,$(guaya_pos));
    7=Dbus(set,guaya,Prev);Macro(GUAYADEQUE_TITLE);
    8=Dbus(set,guaya,Stop);Set(title,Stopped);Timer(GUAYADEQUE_TITLE,cancel);
    9=Dbus(set,guaya,Next);Macro(GUAYADEQUE_TITLE);
    * *=Macro(GUAYADEQUE_HELP);
    *=Macro(GUAYADEQUE_TITLE);
    0=Dbus(set,guaya, Pause);Macro(GUAYADEQUE_TITLE);
    #=Set(fullscreen,toggle);
    [ModeEnd]
    %
    % Will be used if compiled without dbus support
    %
    [Mode]=guayadeque_nodbus
    (EnterMode)=Macro(GUAYADEQUE_TITLE);\
        Macro(ALLIN1MENU);
    
    GETPOS=Make(var,guaya_pos,qdbus org.mpris.guayadeque /Player PositionGet);
    Cancel=Exec(dbus-send --type=method_call --dest=org.mpris.guayadeque / org.freedesktop.MediaPlayer.Quit);\
        Exit;
    Back=Set(text,close);\
        Macro(ALLIN1MENU);
    1=Emulate(key,AudioLowerVolume);
    2=Emulate(key,AudioMute);\
        Timer(MuteTimer,1,1);
    3=Emulate(key,AudioRaiseVolume);
    4=Macro(GETPOS);\
        Exec(dbus-send --type=method_call --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.PositionSet int32:`expr $(guaya_pos) - 10000`);
    5=Exec(dbus-send --type=method_call --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.Play);Macro(GUAYADEQUE_TIMER);
    6=Macro(GETPOS);\
        Exec(dbus-send --type=method_call --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.PositionSet int32:`expr $(guaya_pos) + 10000`);
    7=Exec(dbus-send --type=method_call --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.Prev);Macro(GUAYADEQUE_TITLE);
    8=Exec(dbus-send --type=method_call --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.Stop);Set(title,Stopped);Timer(GUAYADEQUE_TITLE,cancel);
    9=Exec(dbus-send --type=method_call --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.Next);Macro(GUAYADEQUE_TITLE);
    * *=Macro(GUAYADEQUE_HELP);
    * Macro(GUAYADEQUE_TITLE);
    0=Exec(dbus-send --type=method_call --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.Pause);Macro(GUAYADEQUE_TITLE);
    #=Set(fullscreen,toggle);
    [ModeEnd]
    [End]
    

    Regards, Fabian

     
  • Mike
    Mike
    2011-10-17

    would You mind if i add your cfg.file to the next release ?

     
  • Criminal
    Criminal
    2011-10-20

    No, go ahead!
    Hope someone can use it …

    But I have to point out that I didn't test it, when anyremote is compiled without dbus support yet… Maybe I'll give it a shot the next few days. I'll let you know.

     
  • Criminal
    Criminal
    2011-10-20

    Ok, did that. Testing didn't take that long…
    Had to do some minor changes, and XTest support is needed for emulating volume buttons.

    %
    % anyremote configuration file for guayadeque management. (Server-mode)
    %
    % made by Fabian Frank (onlinezeug@gmx.net)
    % ---- based on amarok.cfg (initial version) by Carlos Sanchez
    % working for my purpose ;)
    % XTest support is needed for emulating volume buttons (package libxtst is needed for Debian an Ubuntu I guess)
    GuiAppName=Guayadeque
    GuiAppBinary=guayadeque
    GuiAppVersion=
    GuiAppRun=echo 'A=`pgrep guayadeque`; if [ "x$A" == "x" ]; then echo NOK; else echo OK; fi'|bash -f -s
    GuiAppIcon=amarok.png
    GuiAppType=Application
    GuiAppProtocols=Server
    GuiAppDesc=Guayadeque Music Player
    [Protocol]=Server
    (Init)=Include($(CfgDir)/Utils/aliases-server.cfg);\
        Exec(echo 'P=`which dbus-send|grep dbus-send|grep -v no|wc -l|tr -d " "`;if [ "x$P" == "x1" ]; then true; else $(CfgDir)/Utils/message.sh "ERROR: dbus-send is not found"; fi'|bash -f -s);\
        Exec(echo 'P=`which qdbus|grep qdbus|grep -v no|wc -l|tr -d " "`; if [ "x$P" == "x1" ]; then true; else $(CfgDir)/Utils/message.sh "ERROR: qdbus is not found"; fi'|bash -f -s);\
    (Connect)=Set(parameter,debug,on);\
        Make(mode,guayadeque);
    (Disconnect)=Timer(GUAYADEQUE_TITLE,cancel);
    GUAYADEQUE_HELP =Set(text,replace,Help, 1 Vol-\n 2 Mute\n 3 Vol+\n 4 Rewind\n 5 Play\n 6 FF\n 7 Prew\n 8 Stop\n 9 Next\n ** Help\n 0 Pause\n # toggle Fullscreen);
    GUAYADEQUE_TITLE=Make(var,art,qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.GetMetadata|grep artist:|sed 's/artist://');\
        Make(var,tit,qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.GetMetadata|grep title:|sed 's/title://');\
        Set(title,$(art) - $(tit));\
        Timer(TitleTimer, reset);
    
    GUAYADEQUE_SET_VOL=Make(var,vol,amixer sget Master|grep "Mono: Playback"|sed 's/  Mono: Playback*.\([0-9]*\).*/\1/g');\
        Make(var,vol,expr `expr $(vol) \* 100` \/ 39);\
        Set(volume,$(vol));
        
    GUAYADEQUE_CHECK_MUTE=Make(var,guaya_mute,amixer sget Master|grep "Mono: Playback"|cut -f8 -d" "|sed 's/\[\([a-z]*\).*/\1/g');\
        Make(var,guaya_mute,echo 'if [ "x$(guaya_mute)" == "xon" ]; then echo ""; else echo "MUTE"; fi'|bash -f -s);\
        Set(status,$(guaya_mute));
    TitleTimer=Macro(GUAYADEQUE_TITLE);
    MuteTimer=Macro(GUAYADEQUE_CHECK_MUTE);
    [Mode]=guayadeque
    (EnterMode)=Exec(echo 'A=`pgrep guayadeque`; if [ "x$A" == "x" ]; then guayadeque 2> /dev/null; fi'|bash -f -s);\
        Set(skin,default,ticker,volume);\
        Timer(TitleTimer,5,0);\
        Set(fullscreen,on);\
        Set(icons,Guayadeque,1,vol_down,2,mute,3,vol_up,4,rewind,5,play,6,forward,7,prev,8,stop,9,next,*,refresh,0,pause,#,fullscreen);\
        Set(font,small);\
        Make(var,guaya_dbus,echo 'if [ "x$(Dbus)" == "xyes" ]; then echo guayadeque_dbus; else echo guayadeque_nodbus; fi'|bash -f -s);\
        Make(mode,$(guaya_dbus));
    [ModeEnd]
    %
    % Will be used if compiled with dbus support
    %
    [Mode]=guayadeque_dbus
    (EnterMode)=Dbus(connect,guaya,org.mpris.guayadeque,/Player,org.freedesktop.MediaPlayer);\
        Dbus(connect,guaya2,org.mpris.guayadeque,/,org.freedesktop.MediaPlayer);\
        Macro(GUAYADEQUE_TITLE);\
        Macro(GUAYADEQUE_SET_VOL);\
        Macro(GETPOS);\
        Macro(ALLIN1MENU);\
    GETPOS=Dbus(get,guaya,PositionGet,int,guaya_pos);
    Cancel=Dbus(set,guaya2,Quit);Exit;
    Back=Set(text,close);\
        Macro(ALLIN1MENU);
    1=Emulate(key,AudioLowerVolume);\
        Macro(GUAYADEQUE_SET_VOL);\
        Macro(GUAYADEQUE_SET_VOL);
    2=Emulate(key,AudioMute);\
        Timer(MuteTimer,1,1);
    3=Emulate(key,AudioRaiseVolume);\
        Macro(GUAYADEQUE_SET_VOL);\
        Macro(GUAYADEQUE_SET_VOL);
    4=Macro(GETPOS);\
        Make(var,guaya_pos,expr $(guaya_pos) - 10000);\
        Dbus(set,guaya,PositionSet,int,$(guaya_pos));
    
    5=Dbus(set,guaya,Play);Macro(GUAYADEQUE_TITLE);
    6=Macro(GETPOS);\
        Make(var,guaya_pos,expr $(guaya_pos) + 10000);\
        Dbus(set,guaya,PositionSet,int,$(guaya_pos));
    7=Dbus(set,guaya,Prev);Macro(GUAYADEQUE_TITLE);
    8=Dbus(set,guaya,Stop);Set(title,Stopped);Timer(GUAYADEQUE_TITLE,cancel);
    9=Dbus(set,guaya,Next);Macro(GUAYADEQUE_TITLE);
    * *=Macro(GUAYADEQUE_HELP);
    *=Macro(GUAYADEQUE_TITLE);
    0=Dbus(set,guaya, Pause);Macro(GUAYADEQUE_TITLE);
    #=Set(fullscreen,toggle);
    [ModeEnd]
    %
    % Will be used if compiled without dbus support
    %
    [Mode]=guayadeque_nodbus
    (EnterMode)=Macro(GUAYADEQUE_TITLE);\
        Macro(GUAYADEQUE_SET_VOL);\
        Macro(ALLIN1MENU);
    
    GETPOS=Make(var,guaya_pos,qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.PositionGet);
    Cancel=Exec(dbus-send --type=method_call --dest=org.mpris.guayadeque / org.freedesktop.MediaPlayer.Quit);\
        Exit;
    Back=Set(text,close);\
        Macro(ALLIN1MENU);
    1=Emulate(key,AudioLowerVolume);\
        Macro(GUAYADEQUE_SET_VOL);\
        Macro(GUAYADEQUE_SET_VOL);
    2=Emulate(key,AudioMute);\
        Timer(MuteTimer,1,1);
    3=Emulate(key,AudioRaiseVolume);\
        Macro(GUAYADEQUE_SET_VOL);\
        Macro(GUAYADEQUE_SET_VOL);
    4=Macro(GETPOS);\
        Exec(dbus-send --type=method_call --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.PositionSet int32:`expr $(guaya_pos) - 10000`);
    5=Exec(dbus-send --type=method_call --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.Play);Macro(GUAYADEQUE_TIMER);
    6=Macro(GETPOS);\
        Exec(dbus-send --type=method_call --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.PositionSet int32:`expr $(guaya_pos) + 10000`);
    7=Exec(dbus-send --type=method_call --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.Prev);Macro(GUAYADEQUE_TITLE);
    8=Exec(dbus-send --type=method_call --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.Stop);Set(title,Stopped);Timer(GUAYADEQUE_TITLE,cancel);
    9=Exec(dbus-send --type=method_call --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.Next);Macro(GUAYADEQUE_TITLE);
    * *=Macro(GUAYADEQUE_HELP);
    * Macro(GUAYADEQUE_TITLE);
    0=Exec(dbus-send --type=method_call --dest=org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.Pause);Macro(GUAYADEQUE_TITLE);
    #=Set(fullscreen,toggle);
    [ModeEnd]
    [End]
    

    Regards, Fabian