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

Add option to power up bluetooth controller #22685

Merged
merged 1 commit into from Feb 17, 2017
Merged

Conversation

rnhmjoj
Copy link
Contributor

@rnhmjoj rnhmjoj commented Feb 11, 2017

Motivation for this change

I have been using a udev rule to automatically power up the default bluetooth controller however after the upgrade to systemd 232 this method stopped working due to a change in the systemd-udevd unit.
A possible fix (found here) is to add AF_BLUETOOTH to the RestrictAddressFamilies option.

So I added this fix and also an handy option which implements the power up rule.

Things done

I tested this change and it's working ok.


@mention-bot
Copy link

@rnhmjoj, thanks for your PR! By analyzing the history of the files in this pull request, we identified @heydojo, @abbradar and @edolstra to be potential reviewers.

wantedBy = [ "bluetooth.target" ];
aliases = [ "dbus-org.bluez.service" ];
systemd-udevd.serviceConfig.RestrictAddressFamilies =
"AF_UNIX AF_NETLINK AF_INET AF_INET6 AF_BLUETOOTH";
Copy link
Member

@Mic92 Mic92 Feb 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer a service with the correct permissions rather then changing security defaults of udevd. A service can be started from udev using:

 ACTION=="add", KERNEL=="hci[0-9]*", ENV{SYSTEMD_WANTS}="bluetooth-power@%k.service"

I don't know if %k can be used above in the way I did.

# bluetooth-power@.service
[Unit]
Description=Bluetooth auto power on
After=bluetooth.service sys-subsystem-bluetooth-devices-%i.device suspend.target

[Service]
Type=oneshot
ExecStart=${pkgs.bluez}/bin/hciconfig %i up

[Install]
WantedBy=suspend.target

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this works as well.

@rnhmjoj
Copy link
Contributor Author

rnhmjoj commented Feb 15, 2017

Merge?

@joachifm joachifm merged commit 5231d0a into NixOS:master Feb 17, 2017
@rnhmjoj
Copy link
Contributor Author

rnhmjoj commented Feb 17, 2017

Thank you

@rnhmjoj rnhmjoj deleted the bluetooth branch September 12, 2017 22:57
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

Successfully merging this pull request may close these issues.

None yet

5 participants