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

51 lines
3.4 KiB
Markdown

---
title: "How to disable Bluetooth on Cinnamon startup"
date: 2022-01-31 11:35
url: how-to-disable-bluetooth-on-cinnamon-startup
layout: post
category: Tutorials
image: /img/blog/how-to-disable-bluetooth-on-cinnamon-startup_1.png
description: "Some minor issues never disappear"
---
[![A missing blog post image](/img/blog/how-to-disable-bluetooth-on-cinnamon-startup_1.png)](/img/blog/how-to-disable-bluetooth-on-cinnamon-startup_1.png)
### 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](https://www.preining.info/blog/2022/01/future-of-my-packages-in-debian/), I still had have to manually turn off Bluetooth on startup, as somehow, this state [does](https://medium.com/@vxp/solved-how-to-disable-bluetooth-at-startup-on-linux-mint-19-tara-cinnamon-f5e0bd97e14d) [not](https://github.com/linuxmint/cinnamon/issues/1244) [persist](https://github.com/linuxmint/cinnamon/issues/9072) across reboots, and this feature does not seem implemented by the [Blueman applet](https://github.com/blueman-project/blueman).
### The problem
It appears since [BlueZ](http://www.bluez.org/) 5.35 (2015 !) that [enabling or disabling daemon automatic startup is possible](https://github.com/blueman-project/blueman/wiki/Troubleshooting#turn-on-bluetooth-device-on-boot).
The thing is, even if you manually revert [the Debian-packaged configuration enabling `AutoStart`](https://salsa.debian.org/bluetooth-team/bluez/-/blob/88b298b5d944371dc5a184b92aa420c1a4bb4f98/debian/patches/main.conf.patch), the [Blueman applet will ensure Bluetooth is correctly turned on when bootstrapping](https://github.com/blueman-project/blueman/blob/7ed1b6b148a26772d034d8ee2d648438e7d60b09/blueman/Functions.py#L68), resulting in :
[![A missing blog post image](/img/blog/how-to-disable-bluetooth-on-cinnamon-startup_2.png)](/img/blog/how-to-disable-bluetooth-on-cinnamon-startup_2.png)
... 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](https://www.freedesktop.org/software/systemd/man/systemd.service.html#ExecStart=) `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](https://www.preining.info/) for maintaining all those pieces of software available in Debian, for all these years, including [Cinnamon](https://tracker.debian.org/pkg/cinnamon) :pray: