Skip to content

Instantly share code, notes, and snippets.

@mochaaP
Last active April 17, 2023 23:24
Show Gist options
  • Save mochaaP/4b1ed5c5d4ef2048ddb9f165698da0a8 to your computer and use it in GitHub Desktop.
Save mochaaP/4b1ed5c5d4ef2048ddb9f165698da0a8 to your computer and use it in GitHub Desktop.
Lenovo ThinkPad X1 Carbon (Gen 7) tpacpi::kbd_backlight workaround

Usage

$ usermod -aG user input

add this script to autostart

Requirements

  • libinput
  • light

License

            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  0. You just DO WHAT THE FUCK YOU WANT TO.
#!/usr/bin/env bash
DEVICE="sysfs/leds/tpacpi::kbd_backlight"
LIGHTLEVEL=(0 1 2)
kbdlight_set ()
{
light -r -s "${DEVICE}" -S "$1"
}
kbdlight_get ()
{
light -r -s "${DEVICE}" -G
}
kbdlight_toggle ()
{
CURRENT=$(kbdlight_get)
# Get the next light level (wrapped)
for ((i = 0; i < ${#LIGHTLEVEL[@]}; i++)); do
if [[ ${LIGHTLEVEL[$i]} -eq $CURRENT ]]; then
NEXT=${LIGHTLEVEL[$((i + 1)) % ${#LIGHTLEVEL[@]}]}
break
fi
done
kbdlight_set "$NEXT"
}
while read -r line; do
if [[ $line == *"KEY_KEYBOARD (374) released"* ]]; then
kbdlight_toggle
fi
done < <(stdbuf -oL libinput debug-events --device /dev/input/by-path/platform-thinkpad_acpi-event &)
@mochaaP
Copy link
Author

mochaaP commented Apr 17, 2023

ok i guess i'm kinda dumb on this one. the backlight toggle key combination is Fn+Space.

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