The Hijacked Input
Bluetooth in Ubuntu is managed by the BlueZ stack. By design, if you have previously paired a Bluetooth keyboard with your Ubuntu machine, BlueZ will attempt to establish a connection whenever that keyboard broadcasts its availability. This is generally convenient. However, if you use a multi-device Bluetooth keyboard (like the Logitech MX Keys) and switch it over to type on your tablet, Ubuntu might aggressively try to snatch the connection back. Alternatively, if your keyboard wakes from sleep while you are watching a movie, Ubuntu might automatically reconnect, triggering an on-screen notification and sometimes disrupting active media playback.
Configuring the BlueZ Connection Policy
To retain control over your input devices and stop Ubuntu from automatically reconnecting to your Bluetooth keyboard without your explicit instruction, you must modify the underlying BlueZ daemon configuration.
Open a terminal window (press Ctrl+Alt+T). You need to edit the main Bluetooth configuration file as the root user. Type sudo nano /etc/bluetooth/main.conf and press Enter (enter your password when prompted). Use the arrow keys to scroll down until you locate the [Policy] section. Look for the configuration line governing connection attempts. If you don’t see it, add the following line under [Policy]: ReconnectAttempts=0. This tells the Bluetooth daemon to never proactively attempt to reconnect to a known device. Press Ctrl+O and Enter to save the file, then Ctrl+X to exit the nano editor. Finally, restart the Bluetooth service to apply the changes by typing sudo systemctl restart bluetooth. Your keyboard will remain paired, but it will only connect when you manually select it from the Bluetooth menu in the top right corner of your screen.