Situatie
If your Arch Linux computer supports Bluetooth but you’re not using it, it’ll just be wasting power. Instead of turning it off whenever you boot your computer, disable the Bluetooth service instead.
Solutie
Not Using Bluetooth? Turn it Off
Bluetooth is a convenient way to wirelessly connect all manner of devices to your computer. But if you’re not planning on using Bluetooth, leaving it activated means it’ll be sitting in the background consuming power needlessly. On a laptop that means your battery discharges faster than it needs to.
Depending on how your Bluetooth is configured, it might be broadcasting its ID to other devices too, soliciting connections. This is poor for security and bad for your privacy. Turning Bluetooth on and off is a trivial matter through your desktop environment. Most desktop environments provide a simple checkbox or slider control to do this. But turning it back on is just as easy, and could be done inadvertently if you, or anyone else, isn’t paying attention.
If you really want to be sure Bluetooth can’t be turned on, disabling it is the safest thing to do. With Bluetooth disabled, it cannot be restored through your desktop environment. Your computer will behave as though it had no Bluetooth hardware installed at all.
The good news is, disabling your Bluetooth is easy when you know how, and it’s just as easy to restore it when you do want to use it. We’re using Arch as the demonstration system, but this will work with all modern systemd-based Linux distributions.
Turning Bluetooth Off in GNOME
If all you need to do is turn off Bluetooth temporarily, you can do that very quickly in the GNOME desktop environment. Click the right-hand end of the top bar to access your GNOME System Menu. If you’ve got Bluetooth configured and operational on your computer you’ll see a Bluetooth button.
If Bluetooth is not operational, the button will be greyed out. If it is operational, it’ll be highlighted in one of the accent colors of your current desktop theme. In our test computer’s case, it is a shade of light blue.
Click the Bluetooth button to toggle Bluetooth on and off.
Bluetooth is now off. Clicking the button once more will restore Bluetooth functionality.
Disabling Bluetooth on Arch Linux
Because Arch Linux has been a systemd-based distribution since way back in 2012, we can use the systemd systemctl
command to directly stop and start, and enable and disable, the Bluetooth daemon. You’ll need to have sudo
privileges to do this.
To disable Bluetooth, open a terminal window, and type:
sudo systemctl disable bluetooth
The Bluetooth daemon or service is configured not to automatically launch at boot time, but the current instance of the service is still running. If you reboot your computer, Bluetooth won’t be started.
Meanwhile, if you want to stop Bluetooth right now, without rebooting, use this command:
sudo systemctl stop bluetooth
If you open the GNOME System Menu you’ll see the Bluetooth button is greyed out. Clicking it has no effect. Bluetooth cannot be turned on from within GNOME.
Enabling Bluetooth on Arch Linux
Restoring Bluetooth functionality is just as easy. We use the same systemctl
command with different options. Not surprisingly, instead of disable
we use enable
.
sudo systemctl enable bluetooth
This tells Arch Linux the Bluetooth service should be started when the computer boots. If you want the Bluetooth service to start right now, execute this command:
sudo systemctl start bluetooth
Opening the GNOME System Menu will show you the Bluetooth button is highlighted once more, indicating the Bluetooth service is up and running. Clicking the Bluetooth button toggles Bluetooth on and off, just as before.
Wrapping Bluetooth Commands in Shell Functions
These aren’t particularly difficult commands to remember, but they are quite long. That means it’s easy to mistype them. A neater solution is to create Bash shell functions.
If you already use Bash shell functions, add these functions to your current definitions.
function bluedown() { sudo systemctl disable bluetooth sudo systemctl stop bluetooth } function blueup() { sudo systemctl enable bluetooth sudo systemctl start bluetooth }
If you don’t use Bash shell functions, copy these function definitions to an editor and save the file as “.bash_functions” in your home directory. Then edit your ” .bashrc” file, add these lines to it, and save the file.
# read in shell functions if [ -f ~/.bash_functions ]; then . ~/.bash_functions fi
Our new Bluetooth Bash shell functions will be loaded each time you log in. To load them in right now, you can use the source command “.
” to read your “.bashrc” file.
. .bashrc
Now you can disable and enable your Bluetooth connection with one command in a terminal window.
bluedown
blueup
Save Power and Improve Privacy
Bluetooth consumes power when it is sitting idle because it periodically checks which Bluetooth devices are in the immediate vicinity. If you’re not using Bluetooth you might as well disable it and have that power stay in your laptop battery.
Leave A Comment?