Updated configure_pipewire.sh

This commit is contained in:
Jeremiah Ticket 2022-03-23 05:01:09 -06:00
parent 959fecedf9
commit bb1ef35056

View File

@ -6,8 +6,8 @@ if [[ $(whoami) != "root" ]]; then
# Get the current user's XDG_HOME # Get the current user's XDG_HOME
xdgPath="${XDG_CONFIG_HOME:-$HOME/.config}" xdgPath="${XDG_CONFIG_HOME:-$HOME/.config}"
mkdir -p "$xdgPath/pipewire/pipewire-pulse.conf.d" mkdir -p "$xdgPath/pipewire/pipewire-pulse.conf.d"
mkdir -p "$xdgPath/wireplumber/main.lua.d"
# Warn user if we are going to overwrite an existing default.pa # Warn user if we are going to overwrite an existing 10-console_audio.conf
if [ -f "$xdgPath/pipewire/pipewire-pulse.conf.d/10-console_audio.conf" ]; then if [ -f "$xdgPath/pipewire/pipewire-pulse.conf.d/10-console_audio.conf" ]; then
read -p "This will replace the current file located at $xdgPath/pipewire/pipewire-pulse.conf.d/10-console_audio.conf, press enter to continue or control+c to abort. " continue read -p "This will replace the current file located at $xdgPath/pipewire/pipewire-pulse.conf.d/10-console_audio.conf, press enter to continue or control+c to abort. " continue
fi fi
@ -23,6 +23,37 @@ server.address = [
context.exec = [ context.exec = [
{ path = "pactl" args = "load-module module-switch-on-connect" } { path = "pactl" args = "load-module module-switch-on-connect" }
]' > $xdgPath/pipewire/pipewire-pulse.conf.d/10-console_audio.conf ]' > $xdgPath/pipewire/pipewire-pulse.conf.d/10-console_audio.conf
# Warn user if we are going to overwrite an existing 50-do-not-suspend.lua
if [ -f "$xdgPath/wireplumber/main.lua.d/50-do-not-suspend.lua" ]; then
read -p "This will replace the current file located at $xdgPath/wireplumber/main.lua.d/50-do-not-suspend.lua, press enter to continue or control+c to abort. " continue
fi
echo 'alsa_monitor.rules = {
{
matches = {
{
{ "device.name", "matches", "alsa_card.*" },
},
},
apply_properties = {
["session.suspend-timeout-seconds"] = 0
},
},
{
matches = {
{
{ "node.name", "matches", "alsa_input.*" },
},
{
{ "node.name", "matches", "alsa_output.*" },
},
},
apply_properties = {
["session.suspend-timeout-seconds"] = 0
},
},
}' > $xdgPath/wireplumber/main.lua.d/50-do-not-suspend.lua
echo "If you have not yet done so, please run this script as root to write the client.conf file." echo "If you have not yet done so, please run this script as root to write the client.conf file."
else else
# This section does the root part: # This section does the root part:
@ -72,12 +103,12 @@ autospawn = no
; auto-connect-localhost = no ; auto-connect-localhost = no
; auto-connect-display = no ; auto-connect-display = no
EOF EOF
echo "If you have not yet done so, run this script as your normal user to write the user default.pa" echo "If you have not yet done so, run this script as your normal user to write the user configs"
fi fi
# If there were no errors tell user to restart, else warn them errors happened. # If there were no errors tell user to restart, else warn them errors happened.
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "Configuration created successfully, please restart Pulseaudio or your system, for changes to take affect." echo "Configuration created successfully, please restart both Pipewire-pulseaudio and Wireplumber or your system, for changes to take affect."
else else
echo "Errors were encountered whilst writing the configuration, please correct them manually." echo "Errors were encountered whilst writing the configuration, please correct them manually."
fi fi