RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login
    Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

    Audio change script

    Scheduled Pinned Locked Moved Help and Support
    scriptaudioretropie menu
    3 Posts 2 Posters 208 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      Codafire
      last edited by

      Hi again mates. Im making an script to add a new element to the RetroPie menu, so i can change audio output between HDMI and Jack without entering the dos type menus, only pushing the new option i added.

      The code its the next, im having problems so i dont know where is the problem, any help? Thanks.

      #!/usr/bin/env bash

      AUDIO=0

      if [[AUDIO=0]]; then
      amixer cset numid=3 1
      AUDIO=1
      else [[AUDIO=1]]; then
      amixer cset numid=3 2
      AUDIO=0
      fi

      exit

      Any help?

      1 Reply Last reply Reply Quote 0
      • mituM
        mitu Global Moderator
        last edited by mitu

        Well, I'd suggest you take a primer in Bash scripting, because there's some basic blocks that you're missing. I suggest using the Bash scriptiung guide to get started.

        1. The variables are referenced with $VARNAME,
        2. if testing expression needs space around the condition
          3 . The condition should be ==, = is an assignment operator.
        3. There's no then after else and else does not have a test expression as

        What you want is probably similar to this

        #!/usr/bin/env bash
        
        AUDIO=0
        
        if [[ $AUDIO==0 ]]; then
        echo "Audio zero"
        AUDIO=1
        else
        echo "Audio one"
        AUDIO=0
        fi
        
        1 Reply Last reply Reply Quote 1
        • C
          Codafire
          last edited by

          Thanks a lot, i solved it!!!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post

          Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

          Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.