Skip to content

Instantly share code, notes, and snippets.

@zas
Created Apr 3, 2021
Embed
What would you like to do?
Klim Dash resume after suspend fix / Linux Mint 20.1 / Ubuntu 20.04

Fix for Klim Dash (ID 04d9:a231)/ sleep / wake up / resume / Ubuntu 20.04

This is a fix for Klim Dash USB keyboard not resuming after sleep on Ubuntu 20.04 based systems. Adapted from the Sharkoon PureWriter fix as seen at https://forum.hardware.fr/hfr/OSAlternatifs/Installation/integristes-barbus-femmes-sujet_12264_631.htm#t1445595

Preparation:

Check lsusb output to ensure that's the correct device:

Bus 001 Device 015: ID 04d9:a231 Holtek Semiconductor, Inc. USB-HID Keyboard

Create files /etc/systemd/system/usb-keyboard-reset.sh and /etc/systemd/system/usb-keyboard-reset.service

Enabling:

systemctl enable usb-keyboard-reset

Checking:

Suspend, resume, keyboard should work.

journalctl -u usb-keyboard-reset
-- Logs begin at Sat 2019-07-06 10:22:23 CEST, end at Sat 2021-04-03 13:59:32 CEST. --
avril 03 13:59:13 ifrit5 systemd[1]: Finished Reset Klim Dash RGB keyboard (ID 04d9:a231).
avril 03 13:59:23 ifrit5 systemd[1]: Stopping Reset Klim Dash RGB keyboard (ID 04d9:a231)...
avril 03 13:59:24 ifrit5 usb-keyboard-reset.sh[11023]: Device found: 04d9:a231 authorized set to 0
avril 03 13:59:24 ifrit5 usb-keyboard-reset.sh[11023]: sleep 0.5
avril 03 13:59:24 ifrit5 usb-keyboard-reset.sh[11023]: Device found: 04d9:a231 authorized set to 1
avril 03 13:59:24 ifrit5 systemd[1]: usb-keyboard-reset.service: Succeeded.
avril 03 13:59:24 ifrit5 systemd[1]: Stopped Reset Klim Dash RGB keyboard (ID 04d9:a231).

Notes:

If the keyboard key press doesn't resume the system, you may need to add the following to your udevrules:

cat /etc/udev/rules.d/10-wakeup.rules 
#wakeup holtek usb keyboard
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="04d9", ATTRS{idProduct}=="a231" RUN+="/bin/sh -c 'echo enabled > /sys$env{DEVPATH}/power/wakeup'"
# https://forum.hardware.fr/hfr/OSAlternatifs/Installation/integristes-barbus-femmes-sujet_12264_631.htm#t1445595
# Klim Dash is the same as Sharkoon PureWriter (device is ID 04d9:a232)
[Unit]
Description=Reset Klim Dash RGB keyboard (ID 04d9:a231)
Before=sleep.target
StopWhenUnneeded=yes
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStop=-/etc/systemd/system/usb-keyboard-reset.sh
[Install]
WantedBy=sleep.target
#!/bin/bash
#type lsusb to find "vendor" and "product" ID in terminal
set -euo pipefail
IFS=$'\n\t'
# Klim Dash / Holtek
VENDOR=04d9
PRODUCT=a231
for DIR in $(find /sys/bus/usb/devices/ -maxdepth 1 -type l); do
# printf "\n" $DIR "\n";
if [[ -f $DIR/idVendor && -f $DIR/idProduct &&
$(cat $DIR/idVendor) == $VENDOR && $(cat $DIR/idProduct) == $PRODUCT ]]; then
echo 0 > $DIR/authorized
printf "Device found: %s:%s authorized set to 0\n" $VENDOR $PRODUCT;
sleep 0.5
printf "sleep 0.5\n";
echo 1 > $DIR/authorized
printf "Device found: %s:%s authorized set to 1\n" $VENDOR $PRODUCT;
fi
done
@ziouf
Copy link

ziouf commented Apr 20, 2022

I updated usb-keyboard-reset.service file accordingly to those recommandations : systemd/systemd#6364

# https://forum.hardware.fr/hfr/OSAlternatifs/Installation/integristes-barbus-femmes-sujet_12264_631.htm#t1445595
# Klim Dash is the same as Sharkoon PureWriter (device is ID 04d9:a232)
[Unit]
Description=Reset Klim Dash RGB keyboard (ID 04d9:a231)
After=suspend.target

[Service]
Type=simple
ExecStart=-/etc/init.d/usb-keyboard-reset.sh

[Install]
WantedBy=suspend.target

On my computer it works better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment