Arch Wiki: Bluetooth

I installed:

sudo pacman -Syu bluez bluez-utils
yay broadcom-bt-firmware
sudo systemctl enable --now bluetooth
sudo modprobe btusb

Chat GPT advise:

  1. Load the Bluetooth Kernel Module: Make sure the btusb module is loaded:

    sudo modprobe btusb
    
  2. Restart the Bluetooth Service: Restart the Bluetooth service to ensure it uses the newly installed firmware:

    sudo systemctl restart bluetooth
    

    Ignored that.

  3. Check the System Logs: Verify if there are any errors or relevant messages in the logs:

    dmesg | grep -i bluetooth
    

    May skip too.

  4. Check Bluetooth Status: Use bluetoothctl to see if the Bluetooth controller is now available:

    bluetoothctl
    

    Inside bluetoothctl, run:

    power on
    
  5. Check for Bluetooth Devices: Verify the presence of your Bluetooth device:

    hciconfig -a
    

    No need too, as this tool in the bluez-deprecated-tools package.

If bluetoothctl recognizes your Bluetooth adapter, you can proceed with pairing your device as described previously:

bluetoothctl

Then inside bluetoothctl:

power on
agent on
default-agent
scan on
# Wait for the device to appear and note its MAC address
pair XX:XX:XX:XX:XX:XX
trust XX:XX:XX:XX:XX:XX
connect XX:XX:XX:XX:XX:XX
scan off
exit

If the issue persists, please provide the output of dmesg | grep -i bluetooth and any relevant messages from bluetoothctl.


Connect Automatically

If your Bluetooth device does not automatically reconnect after a reboot, you can automate the process by creating a systemd service or using a udev rule. Here’s how to do it using a systemd service:

Creating a Systemd Service to Automatically Connect Your Bluetooth Device

  1. Create a Script to Connect the Bluetooth Device: Create a script that uses bluetoothctl to connect to your device. Replace XX:XX:XX:XX:XX:XX with your device’s MAC address.

    sudo nano /usr/local/bin/connect_bluetooth_device.sh
    

    Add the following content to the script:

    #!/bin/bash
    
    MAC_ADDRESS="XX:XX:XX:XX:XX:XX"
    
    # Check if Bluetooth is powered on
    if echo 'show' | bluetoothctl | grep -q 'Powered: yes'; then
        # Try to connect to the device
        echo -e "connect $MAC_ADDRESS\nquit" | bluetoothctl
    else
        # Power on Bluetooth and then connect
        echo -e "power on\nconnect $MAC_ADDRESS\nquit" | bluetoothctl
    fi
    

    Save the file and exit the editor.

  2. Make the Script Executable:

    sudo chmod +x /usr/local/bin/connect_bluetooth_device.sh
    
  3. Create a Systemd Service: Create a systemd service unit file:

    sudo nano /etc/systemd/system/connect_bluetooth_device.service
    

    Add the following content to the service file:

    [Unit]
    Description=Connect Bluetooth Device
    After=bluetooth.service
    Requires=bluetooth.service
    
    [Service]
    ExecStart=/usr/local/bin/connect_bluetooth_device.sh
    Type=oneshot
    
    [Install]
    WantedBy=multi-user.target
    
  4. Reload Systemd Daemon: Reload the systemd daemon to recognize the new service:

    sudo systemctl daemon-reload
    
  5. Enable the Service: Enable the service to run at boot:

    sudo systemctl enable connect_bluetooth_device.service
    
  6. Start the Service: Start the service to test if it works:

    sudo systemctl start connect_bluetooth_device.service
    
  7. Reboot and Verify: Reboot your system to verify that the Bluetooth device connects automatically:

    sudo reboot
    

By following these steps, your Bluetooth device should automatically connect after each reboot. If you encounter any issues, please let me know, and I can assist further.


Sway config

# Bluetooth Trackpad
input "1452:782:Trackpad_from_Chiang_Mai,_Winter_2016" {
#        dwt enabled
    tap enabled
    natural_scroll enabled
    middle_emulation enabled
    accel_profile adaptive
    pointer_accel 0.5
    scroll_method two_finger
    tap_button_map lrm
    scroll_factor 0.5
}

On a MacBook Pro there was no working audio, as I have ALSA installed. Seems like, it’s better to instal PipeWire, but I don’t really need Bluetooth here, on this laptop, so I’ll save it for later.

PipeWire is becoming increasingly popular as a versatile multimedia framework, and it offers several advantages over ALSA, especially in the context of managing audio and video streams on Linux systems. Here are some key benefits of using PipeWire over ALSA:

1. Unified Management for Audio and Video:

  • Audio and Video Integration: PipeWire can handle both audio and video streams, which makes it a more comprehensive solution compared to ALSA, which is audio-only.

2. Advanced Features:

  • Low-Latency Audio: PipeWire is designed to provide low-latency audio, which is particularly beneficial for professional audio work and real-time audio applications.
  • Better Bluetooth Support: PipeWire has robust support for Bluetooth audio devices, including handling advanced Bluetooth audio profiles like A2DP and HFP/HSP, with less configuration hassle compared to ALSA.
  • Improved Resampling: PipeWire provides high-quality resampling algorithms, which are often superior to those available in ALSA.

3. Modern Infrastructure:

  • Compatibility with PulseAudio and JACK: PipeWire can act as a drop-in replacement for both PulseAudio and JACK, providing compatibility with applications that rely on these sound servers while offering a modern infrastructure.
  • Flexible Configuration: PipeWire offers a more flexible configuration system, allowing users to tailor audio processing to their specific needs.
  • User-friendly Tools: PipeWire comes with user-friendly tools and utilities that make managing audio devices and streams easier.

4. Better Performance:

  • Efficient Resource Management: PipeWire is designed to be more efficient in managing system resources, which can lead to better overall system performance and reduced CPU usage.
  • Advanced Scheduling: PipeWire provides advanced scheduling capabilities, which can improve the performance of audio processing tasks, particularly in complex audio routing scenarios.

5. Ease of Use:

  • Simplified Configuration: PipeWire often requires less manual configuration to get things working, especially for Bluetooth audio devices, compared to ALSA.
  • Out-of-the-box Support: PipeWire provides better out-of-the-box support for a wide range of audio and video hardware.

Migration Considerations:

  • Transitioning to PipeWire: For users looking to migrate from ALSA (or PulseAudio) to PipeWire, the transition can often be straightforward, with PipeWire automatically handling many aspects of configuration and device management.
  • Community and Development: PipeWire is actively developed and has a growing community, which means it benefits from regular updates, bug fixes, and new features.

Conclusion:

While ALSA is a reliable and mature audio framework, PipeWire offers a modern, unified solution that simplifies the management of audio and video streams, provides advanced features, and generally improves the user experience. For most users, especially those looking for better Bluetooth support and lower-latency audio, PipeWire is a compelling choice.

Steps to Install PipeWire on Arch Linux:

If you decide to switch to PipeWire, here are the steps to install and set it up on Arch Linux:

  1. Install PipeWire and Related Packages:

    sudo pacman -S pipewire pipewire-pulse pipewire-alsa pipewire-jack
    
  2. Enable PipeWire Services:

    sudo systemctl enable --now pipewire pipewire-pulse
    
  3. Remove or Disable PulseAudio (if installed):

    sudo pacman -Rns pulseaudio pulseaudio-bluetooth
    
  4. Configure Bluetooth Audio: PipeWire should automatically handle Bluetooth audio devices. You can manage them using bluetoothctl as you would with other setups.

After setting up PipeWire, you should find it easier to manage audio and video streams, with better support for modern audio devices and use cases.