Problems passing variables to command line

Help
Criminal
2011-10-12
2012-12-10
  • Criminal
    Criminal
    2011-10-12

    Hi there,

    I'm trying to adapt a cfg file to work with guayadeque. I sorted ot most of the things and most commands work fine. The only problem I've got is toggling mute.

    Here's the line I'm having trouble with:

    2=Make(var,guaya_mute,echo 'if [ "x$(guaya_mute)" == "x-1" ]; then qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeGet; qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeSet 0; else qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeSet $(guaya_volume); echo "-1"; fi;'|bash -f -s);
    

    I tried to use the same method as in amarok.cfg, but when I use the cfg file I'm getting the error that guaya_mute and guaya_volume commands are not known. Seems like it's not possible to insert a variable in a bash command like I did.

    Hope one of you has got some hints …

    Regards, Fabian

     
  • Criminal
    Criminal
    2011-10-12

    I created a logfile and this is the output when I'm pressing button 2 (mute):

    [15:38:14] - DBG - [DS]: -------------------- Command read --------------------
    [15:38:14] - DBG - [DS]: parseCommand >+CKEV: 2,1<
    [15:38:14] - DBG - [DS]: Send message to executor thread
    [15:38:14] - DBG - [EX]: got event
    [15:38:14] - DBG - [EX]: got key >+CKEV: 2,1<
    [15:38:14] - DBG - [EX]: handle_command
    [15:38:14] - DBG - [EX]: handle_key_press() >2<
    [15:38:14] - DBG - findItemInMode >guayadeque_dbus,2<
    [15:38:14] - DBG - handleCmdByKey() >2<
    [15:38:14] - DBG - getCommand for >2<
    [15:38:14] - INF - processOneCommand >var,guaya_mute< >echo 'if [ "x$(guaya_mute)" == "x-1" ]; then qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeGet; qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeSet 0; else qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeSet $(guaya_volume); echo "-1"; fi;'|bash -f -s< >1<
    [15:38:14] - INF - Command: Make
    [15:38:14] - INF - Command: Make(var,...)
    [15:38:14] - DBG - substParams >echo 'if [ "x$(guaya_mute)" == "x-1" ]; then qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeGet; qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeSet 0; else qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeSet $(guaya_volume); echo "-1"; fi;'|bash -f -s<
    [15:38:14] - DBG - execSimpleCmd >echo 'if [ "x$(guaya_mute)" == "x-1" ]; then qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeGet; qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeSet 0; else qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeSet $(guaya_volume); echo "-1"; fi;'|bash -f -s<
    [15:38:14] - DBG - execNoFork >echo 'if [ "x$(guaya_mute)" == "x-1" ]; then qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeGet; qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeSet 0; else qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeSet $(guaya_volume); echo "-1"; fi;'|bash -f -s > /home/fabian/.anyRemote/anyremote.result<
    [15:38:14] - DBG - [DS]: -------------------- Command read --------------------
    [15:38:14] - DBG - [DS]: parseCommand >+CKEV: 2,0<
    [15:38:14] - DBG - [DS]: Send message to executor thread
    [15:38:15] - DBG - readResultsFile >146<
    [15:38:15] - DBG - setVar() >guaya_mute->Error: org.freedesktop.DBus.Error.UnknownMethod
    Method "VolumeSet" with signature "" on interface "org.freedesktop.MediaPlayer" doesn't exist
    -1
    <
    [15:38:15] - DBG - [EX]: got event
    [15:38:15] - DBG - [EX]: got key >+CKEV: 2,0<
    [15:38:15] - DBG - [EX]: handle_command
    [15:38:15] - DBG - [EX]: Clean auto repeat flag
    [15:38:18] - DBG - [DS]: -------------------- Command read --------------------
    [15:38:18] - DBG - [DS]: parseCommand >+CKEV: 2,1<
    [15:38:18] - DBG - [DS]: Send message to executor thread
    [15:38:18] - DBG - [EX]: got event
    [15:38:18] - DBG - [EX]: got key >+CKEV: 2,1<
    [15:38:18] - DBG - [EX]: handle_command
    [15:38:18] - DBG - [EX]: handle_key_press() >2<
    [15:38:18] - DBG - findItemInMode >guayadeque_dbus,2<
    [15:38:18] - DBG - handleCmdByKey() >2<
    [15:38:18] - DBG - getCommand for >2<
    [15:38:18] - INF - processOneCommand >var,guaya_mute< >echo 'if [ "x$(guaya_mute)" == "x-1" ]; then qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeGet; qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeSet 0; else qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeSet $(guaya_volume); echo "-1"; fi;'|bash -f -s< >1<
    [15:38:18] - INF - Command: Make
    [15:38:18] - INF - Command: Make(var,...)
    [15:38:18] - DBG - substParams >echo 'if [ "x$(guaya_mute)" == "x-1" ]; then qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeGet; qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeSet 0; else qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeSet $(guaya_volume); echo "-1"; fi;'|bash -f -s<
    [15:38:18] - DBG - searchVar() OK
    [15:38:18] - DBG - Add bytes: 132
    [15:38:18] - DBG - Allocate >449< bytes for parametrized command
    [15:38:18] - DBG - cur cmd >echo 'if [ "x$(guaya_mute)" == "x-1" ]; then qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeGet; qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeSet 0; else qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeSet $(guaya_volume); echo "-1"; fi;'|bash -f -s<
    [15:38:18] - DBG - papameterized >$(guaya_mute)" == "x-1" ]; then qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeGet; qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeSet 0; else qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeSet $(guaya_volume); echo "-1"; fi;'|bash -f -s<
    [15:38:18] - DBG - substitute: searchVar() OK
    [15:38:18] - DBG - cmd var value >echo 'if [ "xError: org.freedesktop.DBus.Error.UnknownMethod
    Method "VolumeSet" with signature "" on interface "org.freedesktop.MediaPlayer" doesn't exist
    -1<
    [15:38:18] - DBG - cur cmd >" == "x-1" ]; then qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeGet; qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeSet 0; else qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeSet $(guaya_volume); echo "-1"; fi;'|bash -f -s<
    [15:38:18] - DBG - papameterized >$(guaya_volume); echo "-1"; fi;'|bash -f -s<
    [15:38:18] - DBG - final cmd >echo 'if [ "xError: org.freedesktop.DBus.Error.UnknownMethod
    Method "VolumeSet" with signature "" on interface "org.freedesktop.MediaPlayer" doesn't exist
    -1" == "x-1" ]; then qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeGet; qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeSet 0; else qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeSet $(guaya_volume); echo "-1"; fi;'|bash -f -s< 448
    [15:38:18] - DBG - execSimpleCmd >echo 'if [ "xError: org.freedesktop.DBus.Error.UnknownMethod
    Method "VolumeSet" with signature "" on interface "org.freedesktop.MediaPlayer" doesn't exist
    -1" == "x-1" ]; then qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeGet; qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeSet 0; else qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeSet $(guaya_volume); echo "-1"; fi;'|bash -f -s<
    [15:38:18] - DBG - execNoFork >echo 'if [ "xError: org.freedesktop.DBus.Error.UnknownMethod
    Method "VolumeSet" with signature "" on interface "org.freedesktop.MediaPlayer" doesn't exist
    -1" == "x-1" ]; then qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeGet; qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeSet 0; else qdbus org.mpris.guayadeque /Player org.freedesktop.MediaPlayer.VolumeSet $(guaya_volume); echo "-1"; fi;'|bash -f -s > /home/fabian/.anyRemote/anyremote.result<
    [15:38:18] - DBG - readResultsFile >146<
    [15:38:18] - DBG - setVar() >guaya_mute->Error: org.freedesktop.DBus.Error.UnknownMethod
    Method "VolumeSet" with signature "" on interface "org.freedesktop.MediaPlayer" doesn't exist
    -1
    <
    

    Maybe this helps.

    The variables guaya_mute and guaya_volume are set during (Enter Mode).

    Regards, Fabian

     
  • Mike
    Mike
    2011-10-14

    I saw the following:
    "Method "VolumeSet" with signature "" on interface "org.freedesktop.MediaPlayer" doesn't exist "

    this means that variable $(guaya_volume) not set at that moment. Please, be sure i have set it before
    use 2=Make(var,guaya_mute, …) command

     
  • Criminal
    Criminal
    2011-10-14

    Got it now.
    There was a missing \ sign causing all the trouble. So my variable wasn't declaed correctly, as you said.

    Still, when I'm using above method, there seems to be a problem with my variable. echo "-1" is not set into the variable correctly. When printing the cariable using echo "Var: x$(guaya_mute)" the output in console is:
    Var: x
    -1

    so the -1 is put into a new line which messes up the comparison with x-1.

    I found a workaround by using some code from xmultimedia.cfg and emulating audio keys.  Works fine, at least for me.
    Will try to show the current track on the java device and current volume, then I'll publish the file in cfg section.

    Thanks for your help!