Bluetooth Keyboard and mouse disconnect when idle for a few seconds and reconnects when moved / typed on Ubuntu 20.04

7,649

Solution 1

Increase the IdleTimeout in /etc/bluetooth/input.conf or set it to 0 to disable it.

You can also try setting FastConnectable to true in /etc/bluetooth/main.conf to allow the devices to reconnect faster at the trade off of increased power consumption.

Restart blue tooth after any changes: sudo service bluetooth restart

Solution 2

You didn't make it clear if you'd gone through the GUI and power settings, so I'll take a stab at this.

Open your power settings and disable the ability to suspend Bluetooth devices to save power.

Ubuntu 20.04 power management - bluetooth

Solution 3

After trying several things, the following seems to have fixed the problem for me:

  1. Instal tlp: sudo apt install tlp
  2. sudo nano /etc/tlp.conf
  3. Change the parameter USB_BLACKLIST_BTUSB from 0 to 1
Share:
7,649
Miquel
Author by

Miquel

Updated on September 18, 2022

Comments

  • Miquel
    Miquel almost 2 years

    I have a keyboard K850 and a M720 Triathlon mouse both from Logitech. They work correctly but get disconnected when idle.

    The behaviour seems to be like an auto suspend function where the device disconnects after a few seconds and reconnects when there is interaction. It makes the use of these device tedious, specially the keyboard as it does not remember the key strokes when it reactivates and it takes a few secs to become responsive again.

    I researched online and found a few solutions related to autosuspend of bluetooth and usb. For instance I tried the following line in grub:

    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash btusb.enable_autosuspend=n usbcore.autosuspend=-1 usbcore.autosuspend_delay_ms=-1"

    Which does not work for me.

    This is a session with bluetoothctl:

    root@balearics:~# bluetoothctl
    Agent registered
    [CHG] Controller 5C:87:9C:35:87:83 Pairable: yes
    [M720 Triathlon]# devices
    Device C9:58:68:E2:1A:D9 M720 Triathlon
    Device DA:95:18:89:C3:30 Keyboard K850
    [CHG] Device C9:58:68:E2:1A:D9 ServicesResolved: no
    [CHG] Device C9:58:68:E2:1A:D9 Connected: no
    [CHG] Device C9:58:68:E2:1A:D9 Connected: yes
    [CHG] Device C9:58:68:E2:1A:D9 ServicesResolved: yes
    [CHG] Device DA:95:18:89:C3:30 ServicesResolved: no
    [CHG] Device DA:95:18:89:C3:30 Connected: no
    [CHG] Device DA:95:18:89:C3:30 Connected: yes
    [CHG] Device DA:95:18:89:C3:30 ServicesResolved: yes
    [M720 Triathlon]#
    

    As you can see after idling it gets disconnected and when I touch it / type it gets connected again.

    Any help would be appreciated

    • GunJack
      GunJack almost 4 years
      Please post the output of tlp-stat
    • Miquel
      Miquel almost 4 years
      tlp is not installed
    • Томица Кораћ
      Томица Кораћ almost 4 years
      @Miquel perhaps it's worth checking if your keyboard/mouse battery should be replaced?
  • Miquel
    Miquel almost 4 years
    IdleTimeout has been set to 0 and FastConnectable to true but no change. Both mouse and keyboard disconnect after some idle time (a few seconds)
  • Miquel
    Miquel almost 4 years
    s, I saw that, but BT is turned off as soon as I switch that off :(
  • Miquel
    Miquel almost 4 years
    I already tried this: miquel@balearics:~$ cat /etc/modprobe.d/disable.autosuspend.conf # Disable autosuspend for btusb to make the bluetooth keyboard work again options btusb enable_autosuspend=n
  • nobody
    nobody almost 4 years
    Okay, i think it should be a number. enable_autosuspend:Enable USB autosuspend by default (bool) what gives cat /sys/module/btusb/parameters/enable_autosuspend please?
  • KGIII
    KGIII almost 4 years
    @Miquel, can you share your power management settings? In this case, they'll have to be screenshots. Usually that's frowned upon, but I can't think of a way to get them in plain text. Check all your power management settings.
  • Miquel
    Miquel almost 4 years
    I tried both n and 0 none worked. miquel@balearics:~$ cat /sys/module/btusb/parameters/enable_autosuspend
  • Miquel
    Miquel almost 4 years
    I can't add images, but power settings are: Blank Screen: Never Wi-FI can be turned off to save power is Off. Bluetooth can be turned off to save power is ON (because what I said, if I turn that off as you suggest Bluetooth disconects entirely).
  • KGIII
    KGIII almost 4 years
    You can edit your initial question and add images, if need be. If you do, be sure to ping me.
  • user1182474
    user1182474 about 3 years
    Helped with Ubuntu 21.04 + Microsoft Wireless Laser Mouse 8000(the FastConnectable significantly decreased the reconnecting after the mouse sleep) and Microsoft Precision Mouse (IdleTimeout, that I had already set before, improved the the delay after the mouse sleep).
  • Greg
    Greg about 3 years
    Wow - that may be the worst bit of UI design i've ever seen. That switch does not control "switching off of bluetooth to save power" instead it controls bluetooth power (its the off switch). The words underneath mean "power might be reduced if you turn this off", not whether its allowed to turn off bluetooth.
  • Radix Salvilines
    Radix Salvilines over 2 years
    Did not work for me in Ubuntu 20.04 with Logitech Triathlon M720, still getting reconnect lag.
  • Admin
    Admin about 2 years
    This is the worst advice ever. Consider this as a solution is ridiculous.... The button turns off Bluetooth instead of turn off the power management for bluetooth. In fact this power management for bluetooth in linux is disabled by default as said on /etc/bluetooth/input.conf # Set idle timeout (in minutes) before the connection will # be disconnect (defaults to 0 for no timeout) Bluetooth implementation in linux is a crap
  • Admin
    Admin almost 2 years
    saved my life!!