1

How do you disable Bluetooth on startup? I found a few solutions but non of them worked, so I was wondering how can I create a script that will run on each system startup, and perform an action to kill the bluetooth service so I can manually enable it later when I need it?

laslozr
  • 53
  • Hello and welcome to AskUbuntu! What exactly is your question? – Daniele Santi Sep 17 '18 at 14:17
  • To have a chance on not getting close you will need to redo this as a Q+A kind of thing. So a question and an answer separate from each other. – Rinzwind Sep 17 '18 at 14:54
  • Hi there, so basically I found an article with this question, but I couldn't post an answer or comment so I created a new topic with a solution to it. How would I be able to post this solution as an answer to the topic that was opened? – laslozr Sep 17 '18 at 19:29
  • I wanted to answer there with my solution, since non of those answer were working for me, but I can't because that thread is protected by the community so I opened this thread instead. – laslozr Sep 18 '18 at 23:01

1 Answers1

0

With a little tweaking I found a solution and 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]
Description=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