Skip to content

Instantly share code, notes, and snippets.

@leogama
Created September 14, 2021 00:27
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save leogama/35961ec0d279e6cf409f783c3851569e to your computer and use it in GitHub Desktop.
Save leogama/35961ec0d279e6cf409f783c3851569e to your computer and use it in GitHub Desktop.
Script to setup PulseAudio equalizer module + qpaeq GUI as a desktop application
#!/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!'
@OmeCor
Copy link

OmeCor commented Dec 26, 2021

Thank you! I had a hard time getting my equalizer to work on Mint 20.2. I came cross your comment on askubuntu.com and ran your script. Glad to say my equalizer runs fine again. My reputation on StackExchange/superuser.com is not high enough, so I'm using this to thank you and letting others know your script works like a charm. Thanks!

@leogama
Copy link
Author

leogama commented May 17, 2022

@OmeCor I'm happy it helped =)

@Criziz21
Copy link

Criziz21 commented Jun 9, 2023

i lost the sound, thankx

@leogama
Copy link
Author

leogama commented Oct 2, 2023

i lost the sound, thankx

@Criziz21 Why? How? If something went wrong, simply delete the created files and restart your PC at most. You should be fine.

@starski
Copy link

starski commented Feb 28, 2024

<3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment