~scripts
58 itemsDownload ./*

58 itemsDownload ./*

..
display
dzen2
nginx
tiling
vosh
4cdl
4trips
alarm
ambient
battery-monitor
checkit
cleverbot.py
clock
color-gen
colors-hex
colorscheme.sh
compton.sh
dailywall
dmenu
ffthumb
grid
gridmacro
gridmacro.kde
help
importw
indexer
install-all.sh
install-twily.sh
installng
mp3ogg
netspeed.sh
orage
pipes
pipes.x
pipewire_bt.sh
ports
rain
randwall
readystart.sh
rotate.sh
scan.sh
screencast
screencast2
scrot
scrotw
search
skull
slocker
startblender.sh
starwars
streamit
sumnum
synctimedate.sh
tty-colorize
usrmount
ytp
ytplay
zombie-restart.sh


scriptspipewire_bt.sh
404•  1 year ago•  DownloadRawClose
1 year ago•  404

{}
#!/bin/bash
# Author: Twily     2023
# Description: script for handling pipewire combined streaming bluetooth devices
#
# install packages/setup repository
# sudo add-apt-repository ppa:pipewire-debian/pipewire-upstream
# sudo apt install module-combine-sink,pacrefs,pipewire
# sudo apt install gstreamer1.0-pipewire libpipewire-0.3-{0,dev,modules} libspa-0.2-{bluetooth,dev,jack,modules} pipewire{,-{audio-client-libraries,pulse,media-session,bin,locales,tests}}
# default pipewire configs
#sudo cp /usr/share/pipewire/media-session.d/* /etc/pipewire/media-session.d/ -Rv

# stopping pulse, --start to start
#pulseaudio --kill

echo "Preparing setup new combined sink for bluetooth devices.."
echo "To remove existing combined, restart pipewire or read this script command for command!"
echo ""
echo -n "Also restart Pipewire service? [y/N]: "
read n
if [ "$n" == "y" ] || [ "$n" == "Y" ]; then
    echo "Restarting Pipewire service!"
    echo ""

    # pipewire restart command
    systemctl --user restart pipewire.service pipewire-pulse.service
    echo ""
    echo -n "Done. Press enter to continue bluetooth linking..."
    read p
else
    echo "Skipping restart.."
fi
echo ""
echo "pactl info (confirm pipewire on pulse?)"

# command to confirm if running on pipewire
pactl info
echo ""
echo "sink list pactl"

# command find bluetooth devices once connected
LC_ALL=C pactl list sinks | grep -E 'Name:|node.name'
echo ""
echo "Enter sink type or leave empty (a2dp): "
read sink_type
if [ -z "$sink_type" ]; then
    sink_type="a2dp"
fi
#sink_type="hsp/hfp"
slave_sink1="bluez_output.A7_46_46_C9_53_85.$sink_type-sink"
slave_sink2="bluez_output.8E_D7_2C_F8_32_6C.$sink_type-sink"
virtual_sink_name="my-combined-sink"
echo ""
echo "Creating virtual sink '$virtual_sink_name'"

# 'old' way module-combine-sink :: issue combined volume adjust may not work
#pactl load-module module-combine-sink sink_name=$virtual_sink_name sink_properties=slaves=$slave_sink1,$slave_sink2

# 'new' way module-null-sink :: pipewire official, combined volume adjust works
pactl load-module module-null-sink media.class=Audio/Sink sink_name=$virtual_sink_name channel_map=stereo

# link all bluetooth devices [L|R] to combined sink -
pw-link $virtual_sink_name:monitor_FL $slave_sink1:playback_FL
pw-link $virtual_sink_name:monitor_FR $slave_sink1:playback_FR
pw-link $virtual_sink_name:monitor_FL $slave_sink2:playback_FL
pw-link $virtual_sink_name:monitor_FR $slave_sink2:playback_FR

echo "Done"
echo "Applications as spotify may need restart to output correctly."
echo "If pw-link failed make sure all devices are connected beforehand."
echo ""


# list and remove loaded modules --
#pactl list short modules
#pactl unload-module 536870916


# If having multiple BT interfaces(dongles) on computer and want to disable internal;
# 'hcitool dev' to list devices
# create executable file in /etc/init.d/disable_builtin_bluetooth
# add content below and reboot; ----
#!/bin/bash
#echo "Disabling hci1 bluetooth adapter"
#/usr/sbin/hciconfig hci1 down &

Top
©twily.info 2013 - 2024
twily at twily dot info



2 158 821 visits
... ^ v