From 374ceb7e5eaf13aa0558605def5ceab6ea7e1890 Mon Sep 17 00:00:00 2001 From: Thomas Koch Date: Fri, 24 Feb 2023 11:42:33 +0100 Subject: [PATCH] ThinkPads: model detection adapted for Libreboot Reference: * https://github.com/linrunner/TLP/issues/679 --- bat.d/05-thinkpad | 11 +++++++++-- changelog | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bat.d/05-thinkpad b/bat.d/05-thinkpad index 0b4e7e03..6f501e98 100644 --- a/bat.d/05-thinkpad +++ b/bat.d/05-thinkpad @@ -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 diff --git a/changelog b/changelog index 7339539c..33522060 100644 --- a/changelog +++ b/changelog @@ -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)