Ubuntu – Keyboard repeat/delay is reset occasionally in Ubuntu 18.04

18.04gnomekeyboardxorg

My keyboard repeat & delay settings are occasionaly reverted to slow (apparently default) values under Xorg in Ubuntu 18.04.

In this situation, the actual values (as obtained by xset q) are

auto repeat delay:  500    repeat rate:  30

whereas gsettings get org.gnome.desktop.peripherals.keyboard delay returns:

uint32 250

If I afterwards run gsettings set org.gnome.desktop.peripherals.keyboard delay 250, the keyboard delay / repeat settings are correctly set (xset q then returns auto repeat delay: 250).

There seem to be several triggers for the behavior, one reproducibly being a suspend & wakeup cycle; I wasn't able to reproduce others yet.

My system is a rather freshly installed Ubuntu 18.04 on an A10-5800K with an A78M-E35 board in BIOS (non EFI) mode.

Any hints would be highly appreciated.

Best Answer

You can create a script to automatically reset keyboard repeat rate during resume:

#!/bin/bash

# NAME: keyrepeat
# PATH: /lib/systemd/system-sleep
# CALL: Called from SystemD automatically
# DATE: July 4, 2019.

# NOTE: https://askubuntu.com/questions/1086780/keyboard-repeat-delay-is-reset-occasionally-in-ubuntu-18-04

case $1/$2 in
  pre/*)
    echo "$0: Going to $2..."
        ;;
  post/*)
    echo "$0: Waking up from $2..."
    gsettings set org.gnome.desktop.peripherals.keyboard delay 250
        ;;
esac

Place the script in /lib/systemd/system-sleep.

Make it executable with:

chmod a+x /lib/systemd/system-sleep/keyrepeat

Reboot and then every resume after suspend the command:

gsettings set org.gnome.desktop.peripherals.keyboard delay 250

is automatically run.