Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipewire #10

Open
nottledim opened this issue Apr 14, 2022 · 3 comments
Open

Pipewire #10

nottledim opened this issue Apr 14, 2022 · 3 comments
Milestone

Comments

@nottledim
Copy link

pulseaudio-bluetooth-autoconnect references pulseaudio in systemctl enable. If one is using pipewire then pulseaudio is not installed. Need to accommodate the "new kid on the block".

@protist
Copy link

protist commented Aug 16, 2022

Does this currently not work with pipewire at all? I'm on Arch Linux using pipewire, pipewire-pulse, and wireplumber, and it doesn't seem to work for me. I installed the package, enabled and started bluetooth-autoconnect.service, then tried the following, but it didn't seem to work.

$ systemctl --user enable --now pulseaudio-bluetooth-autoconnect
Unit /usr/lib/systemd/user/pulseaudio-bluetooth-autoconnect.service is added as a dependency to a non-existent unit pulseaudio.service.

My Bluetooth headset didn't automatically connect next time I tried.

I then tested modifying the pulseaudio-bluetooth-autoconnect.service, changing all references of pulseaudio.service to pipewire.service. I started the service, but it immediately completed.

$ systemctl --user status pulseaudio-bluetooth-autoconnect
○ pulseaudio-bluetooth-autoconnect.service - Bluetooth autoconnect service for pipewire
     Loaded: loaded (/usr/lib/systemd/user/pulseaudio-bluetooth-autoconnect.service; enabled; preset: enabled)
     Active: inactive (dead) since Mon 2022-08-15 15:23:06 AEST; 20h ago
   Duration: 85ms
    Process: 3262118 ExecStart=/usr/bin/bluetooth-autoconnect (code=exited, status=0/SUCCESS)
   Main PID: 3262118 (code=exited, status=0/SUCCESS)
        CPU: 77ms

Aug 15 15:23:06 my-hostname systemd[1098]: Started Bluetooth autoconnect service for pipewire.

The service file contains the following:

ExecStart=/usr/bin/bluetooth-autoconnect

So I tested running this manually. Again it just completes immediately. I'm not really sure if this is the command we should be running, so I tested bluetooth-autoconnect -d instead. This indeed stayed open… but my headset didn't automatically connect next time I tried.

On further testing, I should note that bluetooth-autoconnect and bluetooth-autoconnect -d do work if have recently used Bluetooth. However, after not using Bluetooth for a while, the latter does not work at least. Perhaps relevant, I do have Bluetooth's auto-suspend disabled.

$ cat /proc/cmdline
BOOT_IMAGE=/vmlinuz-linux root=UUID=<redacted> rw loglevel=3 cryptdevice=UUID=<redacted>:cryptroot:allow-discards root=/dev/mapper/cryptroot btusb.enable_autosuspend=n

@jrouleau
Copy link
Owner

@protist

This script is effectively the same as runnning bluetoothctl connect <device_mac> for every paired+trusted device either as a oneshot with bluetooth-autoconnect or whenever an adapter powers on with bluetooth-autoconnect -d. This will not magically connect devices that do not announce themselves or are brought in from out of range. Oneshot attempts can be triggered manually whenever you like with bluetooth-autoconnect (e.g. I have the bluetooth icon on my bar trigger bluetooth-autoconnect when clicked for manual "scanning"). The daemon mode is used to connect when an adapter is powered on: pimarily during boot or when resuming from sleep/hibernation.

The pulseaudio-bluetooth-autoconnect service is intended to be a oneshot script that triggers a connection attempt after pulseaudio is started as headsets fail to connect prior to the audio system running and is only relevant during boot. A similar oneshot service would likely be needed for pipewire to autoconnect during boot. I do not have any systems running pipewire so I am unable to test this at this time.

Again, this script is effectively just a wrapper around bluetoothctl connect <device_mac>. Other than providing a convenience service to run itself after pulseaudio starts (manually running bluetooth-autoconnect once after boot would have the same effect), it has nothing to do with which audio system you use. Issues connecting to your devices (i.e. bluetooth-autoconnect says connecting to device ... but the connection fails) are outside the scope of what we can support here. If a connection attempt is not made, ensure that the device is both paired and trusted and that the adapter is connected and powered on.

@protist
Copy link

protist commented Sep 15, 2022

Thank you @jrouleau for the detailed explanation.

Sorry, I should have mentioned that I had subsequently gotten my system working. I previously had the kernel parameter btusb.enable_autosuspend=n, but after changing the =n to =0, it now works as expected. I think I had previously found advice to use =n somewhere, but this didn't seem to work. Now, even without bluetooth-autoconnect, it seems to autoconnect fine in KDE Plasma.

Thanks again.

@jrouleau jrouleau added this to the v2.0 milestone Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants