Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save CyberSys/ae637888a2d44f83207f08fb220bd77a to your computer and use it in GitHub Desktop.

Select an option

Save CyberSys/ae637888a2d44f83207f08fb220bd77a to your computer and use it in GitHub Desktop.

Revisions

  1. @leogama leogama created this gist Sep 14, 2021.
    90 changes: 90 additions & 0 deletions pulseaudio-equalizer-setup.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,90 @@
    #!/bin/sh -ux

    # This is a small script to setup the PulseAudio equalizer as a desktop
    # application that runs just when the 'qpaeq' GUI is open.

    # This is free and unencumbered software released into the public domain.
    #
    # Anyone is free to copy, modify, publish, use, compile, sell, or distribute
    # this software, either in source code form or as a compiled binary, for any
    # purpose, commercial or non-commercial, and by any means.
    #
    # In jurisdictions that recognize copyright laws, the author or authors of
    # this software dedicate any and all copyright interest in the software to
    # the public domain. We make this dedication for the benefit of the public
    # at large and to the detriment of our heirs and successors. We intend this
    # dedication to be an overt act of relinquishment in perpetuity of all
    # present and future rights to this software under copyright law.
    #
    # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
    # THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
    # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
    # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    #
    # For more information, please refer to <https://unlicense.org>


    pulseaudio_dir="${XDG_CONFIG_HOME:-$HOME/.config}/pulse"
    executable_dir="$HOME/.local/bin"
    application_dir="${XDG_DATA_HOME:-$HOME/.local/share}/applications"

    executable_name=pulseaudio-equalizer

    case ":$PATH:" in
    *:"$executable_dir":*)
    app_exec=$executable_name
    ;;
    *)
    executable_dir="$(dirname $application_dir)"
    app_exec="$executable_dir/$executable_name"
    ;;
    esac

    pulseaudio_file="$pulseaudio_dir/default.pa"
    executable_file="$executable_dir/$executable_name"
    application_file="$application_dir/pulseaudio-equalizer.desktop"

    mkdir -p "$pulseaudio_dir" "$executable_dir" "$application_dir"


    cat >"$pulseaudio_file" <<EOF
    .include /etc/pulse/default.pa
    # Needed by module-equalizer-sink.
    load-module module-dbus-protocol
    EOF


    cat >"$executable_file" <<'EOF'
    #!/bin/sh
    pactl load-module module-equalizer-sink
    pactl set-default-sink "$(pactl list sinks short | awk '/equalizer/ { print $2 }')"
    qpaeq
    pactl unload-module module-equalizer-sink
    EOF


    cat >"$application_file" <<EOF
    [Desktop Entry]
    Name=PulseAudio Equalizer
    GenericName=Sound Equalizer
    Type=Application
    Terminal=false
    Exec=${app_exec}
    TryExec=qpaeq
    StartupWMClass=qpaeq
    Icon=audio-headphones
    Categories=Qt;AudioVideo;
    EOF


    chmod +x "$executable_file"

    pulseaudio --kill
    pulseaudio --start

    echo 'Setup finished!'