blog/_posts/2022-01-31-how-to-disable-b...

3.4 KiB

title date url layout category image description
How to disable Bluetooth on Cinnamon startup 2022-01-31 11:35 how-to-disable-bluetooth-on-cinnamon-startup post Tutorials /img/blog/how-to-disable-bluetooth-on-cinnamon-startup_1.png Some minor issues never disappear

A missing blog post image

Introduction

For years now, I've been using Cinnamon as desktop environment on my (graphical) Debian-powered systems.
Whereas this might painfully and sadly change in the future, I still had have to manually turn off Bluetooth on startup, as somehow, this state does not persist across reboots, and this feature does not seem implemented by the Blueman applet.

The problem

It appears since BlueZ 5.35 (2015 !) that enabling or disabling daemon automatic startup is possible.

The thing is, even if you manually revert the Debian-packaged configuration enabling AutoStart, the Blueman applet will ensure Bluetooth is correctly turned on when bootstrapping, resulting in :

A missing blog post image

... and that makes sens, because we can expect the front-end to check whether the back-end is ready on startup. But that's a problem if you want it to stay off (and shut up) unconditionally.

The workaround

The workaround is then to let the Bluetooth daemon automatically start with AutoStart set to true, but directly disabling the wireless device with rfkill.

Unlike many others, I usually prefer handling "system-related issues" with "system-related tools", instead of cheap hooks messy to maintain and always ending up requiring unnecessary privileges.
Using systemd, we can easily implement this using unit overriding and built-in Service execution hooks :

{% highlight bash %} systemctl edit bluetooth.service {% endhighlight %}

... and insert the following :

{% highlight ini %} [Service] ExecStartPost=/usr/sbin/rfkill block bluetooth {% endhighlight %}

Note that we do not reset with an empty string ExecStartPost entry first, so if one day Debian-based distributions decide to add another hook like that, this workaround wouldn't break a thing, and will always be run afterwards.

Last words

Shoot-out to Norbert Preining for maintaining all those pieces of software available in Debian, for all these years, including Cinnamon 🙏