Skip to content

Instantly share code, notes, and snippets.

@yejun
Last active October 28, 2024 17:29
Show Gist options
  • Save yejun/2c1a070a839b3a7b146ede8a998b5495 to your computer and use it in GitHub Desktop.
Save yejun/2c1a070a839b3a7b146ede8a998b5495 to your computer and use it in GitHub Desktop.
Use pulseaudio as bluetooth speaker on archlinux

Install packages

  • bluez
  • bluez-utils
  • pulseaudio-bluetooth

Enable bluetooth

Edit /etc/bluetooth/main.conf, uncomment following lines

[Policy]
AutoEnable=true

Add /etc/bluetooth/audio.conf

[General]
Enable=Source,Sink,Media

Enable and start bluetooth service

sudo systemctl enable bluetooth
sudo systemctl start bluetooth

Follow this guide to connect bluetooth devices. Some devices may need explicitly trust in bluetoothctl.

Enable pulseaudio system wide

Create pulse user, it is very important add pulse to lp group which grants access to bluetooth control dbus

sudo groupadd --system pulse
sudo useradd --system -g pulse -G audio,lp --home-dir /var/run/pulse pulse
sudo groupadd --system pulse-access

Add yourself to lp and pulse-access if necessay.

Add file /etc/systemd/system/pulseaudio.service

[Unit]
Description=PulseAudio Daemon

[Install]
WantedBy=multi-user.target

[Service]
Type=notify
PrivateTmp=true
ExecStart=/usr/bin/pulseaudio --system --realtime --disallow-exit --log-target=journal

Edit /etc/pulse/daemon.conf, uncomment

system-instance = yes

Add these lines to /etc/pulse/system.pa

load-module module-bluetooth-discover
load-module module-bluetooth-policy

Add file /etc/pulse/client.conf

default-server = /var/run/pulse/native
autospawn = no

Enable and start pulseaudio

sudo systemctl enable pulseaudio
sudo systemctl start pulseaudio

Config alsa if necessay, here is my /etc/asound.conf

pcm.!default {
    type plug
    slave {
        pcm "hw:0,0"
    }
}

ctl.!default {
    type hw
    card 0
}

Load pulse module using pacmd

sudo PULSE_RUNTIME_PATH=/var/run/pulse -u pulse pacmd
@leukimi
Copy link

leukimi commented Mar 26, 2024

For Manjaro Cinnamon on old laptop with old bluetooth package bluez-utils was not installed automatically and rebootwas needed to produce sound via bluetooth after reconnecting and pairing bluetooth devices.

There seems to be a possibility to direct the output stream to either the built-in speakers or the 3.5 mm headphone jack. This makes it possible to connect wired external speakers to an Archlinux/Manjaro laptop/desktop and play the sound directly to the external speakers via 3.5mm jack for better sound. Tablets and mobile phones which do not offer an inbuilt 3.5mm jack can be connected to non-bluetooth speakers this way.

# If bluez-utils is not a required dependency to 
# package pulseaudio-bluetooth:

sudo pacman -Sy pulseaudio-bluetooth bluez-utils

# Reconnecting and restarting bluetooth and pulseaudio
# may not produce a sound until reboot

sudo systemctl --user restart pulseaudio bluetooth
sudo reboot

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