Skip to content

Commit

Permalink
ThinkPads: model detection adapted for Libreboot
Browse files Browse the repository at this point in the history
Reference:
* #679
  • Loading branch information
linrunner committed Feb 24, 2023
1 parent 5248ad1 commit 374ceb7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 9 additions & 2 deletions bat.d/05-thinkpad
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,24 @@ check_thinkpad () {
# kernel module thinkpad_acpi is loaded

if [ -z "$X_SIMULATE_MODEL" ]; then
# get DMI product string and sanitize it
# get DMI product_version string and sanitize it
pv="$(read_dmi product_version | tr -C -d 'a-zA-Z0-9 ')"
else
# simulate arbitrary model
pv="$X_SIMULATE_MODEL"
fi

# check DMI product string for occurrence of "ThinkPad"
# stock BIOS: check DMI product_version string for occurrence of "ThinkPad"
if printf '%s' "$pv" | grep -E -q 'Think[Pp]ad'; then
# it's a real ThinkPad --> save model substring
_tpmodel=$(printf '%s\n' "$pv" | sed -r 's/^Think[Pp]ad //')
elif [ -z "$X_SIMULATE_MODEL" ]; then
# Libreboot uses DMI product_name, check it too
pv="$(read_dmi product_name | tr -C -d 'a-zA-Z0-9 ')"
if printf '%s' "$pv" | grep -E -q 'Think[Pp]ad'; then
# it's a librebooted' ThinkPad --> save model substring
_tpmodel=$(printf '%s\n' "$pv" | sed -r 's/^Think[Pp]ad //')
fi
fi
else
# not a ThinkPad: get DMI product string
Expand Down
1 change: 1 addition & 0 deletions changelog
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
'charge_control_end_threshold' provided by kernel 5.18 and newer
- System76 laptops with open source EC firmware:
start and stop threshold
- ThinkPads: model detection adapted for Libreboot (Issue #679)
- Toshiba/Dynabook laptops: stop threshold 80/100%
Configuration:
- Allow comments (#) after parameters (Issue #598)
Expand Down

0 comments on commit 374ceb7

Please sign in to comment.