170 kx #!/bin/bash
170 kx # Copyright 2022 Patrick J. Volkerding, Sebeka, Minnesota, USA
170 kx # All rights reserved.
170 kx #
170 kx # Redistribution and use of this script, with or without modification, is
170 kx # permitted provided that the following conditions are met:
170 kx #
170 kx # 1. Redistributions of this script must retain the above copyright
170 kx # notice, this list of conditions and the following disclaimer.
170 kx #
170 kx # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
170 kx # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
170 kx # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
170 kx # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
170 kx # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
170 kx # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
170 kx # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
170 kx # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
170 kx # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
170 kx # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
170 kx
170 kx # This script will attempt to disable pipewire as the default audio server,
170 kx # changing it back to pulseaudio.
170 kx
170 kx # Remove or rename the XDG autostart files:
170 kx for file in /etc/xdg/autostart/pipewire-media-session.desktop /etc/xdg/autostart/pipewire-pulse.desktop /etc/xdg/autostart/pipewire.desktop ; do
170 kx if [ -r ${file}.sample ]; then
170 kx rm -f $file
170 kx elif [ -r $file ]; then
170 kx mv ${file} ${file}.sample
170 kx fi
170 kx done
170 kx
170 kx # Enable pulseaudio.desktop:
170 kx if grep -q "^Hidden=true$" /etc/xdg/autostart/pulseaudio.desktop ; then
170 kx grep -v "^Hidden=true$" /etc/xdg/autostart/pulseaudio.desktop > /etc/xdg/autostart/pulseaudio.desktop.new
170 kx mv /etc/xdg/autostart/pulseaudio.desktop.new /etc/xdg/autostart/pulseaudio.desktop
170 kx fi
170 kx
170 kx # Edit /etc/pulse/client.conf to enable autospawn:
170 kx sed -i "s/autospawn = no/autospawn = yes/g" /etc/pulse/client.conf
170 kx sed -i "s/allow-autospawn-for-root = no/allow-autospawn-for-root = yes/g" /etc/pulse/client.conf
170 kx
170 kx echo "Pulseaudio enabled as system audio server."
170 kx if ps ax | grep -q pipewire ; then
170 kx echo
170 kx echo "You may need to stop running daemon/pipewire processes."
170 kx echo "The clean way is to run these commands as the user that owns the processes:"
170 kx echo "/usr/bin/daemon --pidfiles=~/.run --name=pipewire --stop"
170 kx echo "/usr/bin/daemon --pidfiles=~/.run --name=pipewire-media-session --stop"
170 kx echo "/usr/bin/daemon --pidfiles=~/.run --name=pipewire-pulse --stop"
170 kx echo
170 kx echo "The quick and dirty way if nothing else on the machine is using the daemon"
170 kx echo "utility is to issue this command:"
170 kx echo "killall daemon"
170 kx fi