Skip to content

Commit

Permalink
tlp-stat: distinguish tp-smapi incompatible hardware from load errors
Browse files Browse the repository at this point in the history
See Issue linrunner#160.
  • Loading branch information
linrunner committed Sep 10, 2015
1 parent 0d82d4d commit fab1b7c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 16 deletions.
5 changes: 4 additions & 1 deletion changelog
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
+++ 0.9 --- 27.08.2015 +++
+++ 0.9 --- 10.09.2015 +++

* Development Release

* Features
Radio Devices:
- Finally remove deprecated DEVICES_TO_ENABLE_ON_RADIOSW code
(works with Ubuntu 12.04/Kernel 3.2 only)
ThinkPad Battery:
- tlp-stat:
- Distinguish tp-smapi incompatible hardware from load errors (Issue #160)

+++ 0.8 --- 05.08.2015 +++

Expand Down
23 changes: 15 additions & 8 deletions tlp-functions.in
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ check_upstart () { # check if upstart is active init system (PID 1)
}

check_openrc () { # check if openrc is the active init system (PID 1)
# rc: 0=yes, 1=no
# rc: 0=yes, 1=no
[ -e /run/openrc/softlevel ]
}

Expand Down Expand Up @@ -222,7 +222,7 @@ load_modules () { # load needed kernel modules

# --- DMI

read_dmi () { # read dmi data -- $*: keywords; stdout: dmi strings
read_dmi () { # read DMI data -- $*: keywords; stdout: dmi strings
local ds key outr

outr=""
Expand All @@ -242,20 +242,27 @@ read_dmi () { # read dmi data -- $*: keywords; stdout: dmi strings

# --- ThinkPad

is_thinkpad () { # check for ThinkPad hardware
is_thinkpad () { # check for ThinkPad hardware and save model string
# rc: 0=ThinkPad, 1=other hardware
# retval: $tpmodel

if [ -d $TPACPIDIR ]; then
# Kernel module thinkpad_acpi is loaded
# kernel module thinkpad_acpi is loaded

# get DMI product string
tpmodel="$( read_dmi product_version )"

# Check dmi product string for occurence of "ThinkPad"
if read_dmi product_version | grep -q "ThinkPad"; then
# It's a real ThinkPad
# check DMI product string for occurence of "ThinkPad"
if echo $tpmodel | grep -q "ThinkPad"; then
# it's a real ThinkPad --> save model substring
tpmodel=${tpmodel#ThinkPad }
tpmodel=${tpmodel#Edge }
return 0
fi
fi

# No ThinkPad detected
# no ThinkPad detected
tpmodel=""
return 1
}

Expand Down
21 changes: 14 additions & 7 deletions tlp-stat.in
Original file line number Diff line number Diff line change
Expand Up @@ -942,8 +942,18 @@ if [ "$show_bat" = "1" ] || [ "$show_all" = "1" ]; then
echo "+++ ThinkPad Extended Battery Functions"
echo -n "tp-smapi = "
case $tpsmapi in
0) echo "active" ;;
2) echo "inactive (kernel module 'tp_smapi' load error)" ;;
0) echo "active" ;;
2) # distingush by model string if incompatible or load error
# $tpmodel preset by is_thinkpad()
case $tpmodel in
"X1 Carbon*"|X2[345]0*|T[45][345][01]*|W5[345][01]*|L[45][345]0|E[1345][05]|S[245][345][01]*)
echo "inactive (incompatible hardware)"
;;

*) echo "inactive (kernel module 'tp_smapi' load error)" ;;
esac
;;

127) echo "inactive (kernel module 'tp_smapi' not installed)" ;;
*) echo "unknown status"
esac
Expand Down Expand Up @@ -1120,11 +1130,8 @@ if [ "$show_all" = "1" ]; then

if is_thinkpad; then
# Add ThinkPad specific suggestions
model="$( read_dmi product_version )"
model=${model#ThinkPad }
model=${model#Edge }

case $model in
# $tpmodel preset by is_thinkpad()
case $tpmodel in
"X1 Carbon*"|X2[345]0*|T[45][345][01]*|W5[345][01]*|L[45][345]0|E[1345][05]|S[245][345][01]*)
[ $tpacpi -eq 127 ] && suout="${suout}Install acpi-call kernel module for ThinkPad advanced battery functions\n"
;;
Expand Down

0 comments on commit fab1b7c

Please sign in to comment.