8

I am using Ubuntu 18.04 on Dell XPS-13 and every time the laptop starts bluetooth is enabled and you have to disable it manual. But i am using it not very often.

Therefore: is it possible to have bluetooth disabled by default? (i know about the tweak in the rc.local file but since Ubuntu 14.04 the rc.local does not exist and is not used anymore)

J.Doe
  • 93
  • Have you tried turning off Bluetooth in Settings? I've done that and the setting is retained after shutdown and reboot – Broadsworde May 11 '18 at 17:59
  • Please clarify. Your title makes it sound like you want to disable bluetooth by default, but then you ask "is it possible to have bluetooth enabled by default? " Several of us can't understand what your problem is due to this Please [edit] your post to provide further clarity. Thank you for helpin us help you! – Elder Geek May 11 '18 at 22:52
  • This is a well known bug. – Pilot6 May 14 '18 at 14:16
  • Im sorry for the confusion between enabled and disabled, i corrected that.

    @Broadsworde if i turn bluetooth off in the settings it is enabled after a restart.

    – J.Doe May 14 '18 at 14:40
  • @Pilot6 but is there a workaround? – J.Doe May 14 '18 at 14:40
  • @J.Doe the settings from the gui does not abide to systemd probably. See if my answer works. – Rinzwind May 14 '18 at 14:58
  • 2
  • @Fabby the other question does not solve the problem. Like i said in my question: the suggested solution there is to use the rc.local file and since ubuntu 14.04 the rc.local is not existent anymore. – J.Doe May 16 '18 at 07:17

2 Answers2

14
gedit /etc/bluetooth/main.conf

and set this:

AutoEnable = false

A more radical way is to either stop the bluetooth service

sudo systemctl stop bluetooth.service

Or even more radical is to disable it permantly

sudo systemctl disable bluetooth
solsTiCe
  • 9,231
Rinzwind
  • 299,756
  • +1 because this ended up in the LQ queue for some or other reason... – Fabby May 14 '18 at 15:41
  • I tried the first solution and disabled bluetooth in the settings if i than reboot my laptop bluetooth is again enabled.

    But i do not want to disable bluetooth permanently just do not have it enabled by default on start.

    – J.Doe May 16 '18 at 07:13
  • Look at the duplicate mentioned in the comments @J.Doe – Fabby May 16 '18 at 10:40
  • @J.Doe the edit is still there in /etc/bluetooth/main.conf? Can you show the status of bluetooth.service in the question? And maybe main.conf too? On my 18.04 BT is disabled and stays disabled and I used the settings to do this. – Rinzwind May 16 '18 at 14:49
  • @Rinzwind yes the edit was/is still in the main.conf

    But "sudo systemctl disable bluetooth" worked and i can still activate bluetooth with the settings if i want to. Thank you

    – J.Doe May 18 '18 at 08:55
  • @J.Doe cool :-) – Rinzwind May 18 '18 at 09:30
  • This doesn't work for me.. – Sandu Ursu Jun 18 '20 at 13:03
  • @SanduUrsu then you are doing something wrong. These 2 have been working for years and still work. I use it every new Ubuntu install and have used it for 20.04 as well. – Rinzwind Jun 18 '20 at 13:12
  • It appears that if you use tlp, and don't disable it there, this solution won't work. – Sandu Ursu Jun 18 '20 at 16:22
1

Here is how you can create a script that will run on startup and perform an action to kill the Bluetooth service, and that would be the following (I use nano, feel free to use any other text editor):

Step 1: Navigate to the folder:

cd /etc/systemd/system/

Step 2: First create a script that will kill the Bluetooth service once run:

nano bluetoothkill.sh

Step 3: Enter the following code, save and exit:

#!/bin/bash
rfkill block bluetooth
exit 0

Step 4: Create a foo.service file in the same folder /etc/systemd/system/ :

nano foo.service

Step 5: Enter the following code, save and exit:

[Unit]
Details=Additional startup scripts
After=network.target

[Service]
ExecStart=/etc/systemd/system/bluetoothkill.sh

[Install]
WantedBy=default.target

Step 6: Run the following command in the terminal:

sudo chmod 744 bluetoothkill.sh

Step 7: Run the following command in the terminal:

sudo systemctl start foo.service

Step 8: Restart the machine and on the next boot you will notice that the Bluetooth service is no longer enabled by default on startup. You can still enable it when ever you like in the settings, or the terminal it is behaving without any errors.

If you like to add more scripts on startup, you can always edit the foo.service file and add additional lines under the [Service] bracket to run additional scripts on startup, for example:

ExecStart=/full-script-filepath/newscript.sh

laslozr
  • 53