Skip to content

Commit

Permalink
tlp-stat: show systems that do not detect AC/charger
Browse files Browse the repository at this point in the history
Currently affected:
* Dell XPS 15 9550/60

References:
* https://linrunner.de/en/tlp/docs/tlp-faq.html#acquirk
* #223
* #343
* #362
  • Loading branch information
linrunner committed Jan 13, 2019
1 parent a2cafc0 commit 7380f51
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 13 deletions.
3 changes: 2 additions & 1 deletion changelog
@@ -1,4 +1,4 @@
+++ 1.2 --- 10.01.2019 +++
+++ 1.2 --- 13.01.2019 +++

*** Development version ***

Expand Down Expand Up @@ -30,6 +30,7 @@
- Check systemd-rfkill.socket masked status
- Disks: show all configured devices (consider default)
- Intel GPU: show frequency limits and available frequencies
- Show systems that do not detect AC/charger (Dell XPS 15 9550/60)
- Rename "Suggestions" section to "Recommendations"
- Remove invocation via 'tlp stat'
* Bugfixes
Expand Down
6 changes: 6 additions & 0 deletions func.d/tlp-func-stat
Expand Up @@ -16,6 +16,7 @@ readonly SMARTCTL=smartctl
readonly SYSTEMCTL=systemctl
readonly SYSTEMD=systemd

readonly RE_AC_QUIRK='^XPS 15 95[56]0$'
readonly RE_ATA_ERROR='ata[0-9]+: SError: {.*CommWake }'

# ----------------------------------------------------------------------------
Expand All @@ -38,6 +39,11 @@ check_openrc () { # check if openrc is the active init system (PID 1)
[ -e /run/openrc/softlevel ]
}

check_ac_quirk () { # check for hardware known not to expose AC device
# $1: model string; rc: 0=yes, 1=no
printf '%s' "$1" | grep -E -q "${RE_AC_QUIRK}"
}

# --- Formatted Output

printparm () { # formatted output of sysfile - general
Expand Down
20 changes: 10 additions & 10 deletions tlp-func-base.in
Expand Up @@ -435,18 +435,18 @@ check_thinkpad () { # check for ThinkPad hardware and save model string,
if [ -d $TPACPIDIR ]; then
# kernel module thinkpad_acpi is loaded

# get DMI product string and sanitize it
pv="$(read_dmi product_version | tr -C -d 'a-zA-Z0-9 ')"
if [ -z "$X_SIMULATE_MODEL" ]; then
# get DMI product 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"
if printf '%s' "$pv" | grep -E -q 'Think[Pp]ad'; then
# it's a real ThinkPad --> save model substring
if [ -z "$X_SIMULATE_MODEL" ]; then
_tpmodel=$(echo $pv | sed -r 's/^Think[Pp]ad //')
else
# debug aid: simulate model via X_SIMULATE_MODEL config
_tpmodel="$X_SIMULATE_MODEL"
fi
_tpmodel=$(echo $pv | sed -r 's/^Think[Pp]ad //')
fi
fi

Expand All @@ -461,12 +461,12 @@ check_thinkpad () { # check for ThinkPad hardware and save model string,
load_modules $MOD_TPACPI
fi

echo_debug "bat" "check_thinkpad: _tpmodel=$_tpmodel"
echo_debug "bat" "check_thinkpad: tpmodel=$_tpmodel"
return 0
fi

# not a ThinkPad
echo_debug "bat" "check_thinkpad.not_a_thinkpad"
echo_debug "bat" "check_thinkpad.not_a_thinkpad: model=$pv"
return 1
}

Expand Down
14 changes: 12 additions & 2 deletions tlp-stat.in
Expand Up @@ -236,8 +236,15 @@ fi # show_conf

if [ "$show_system" = "1" ] || [ "$show_all" = "1" ] ; then
# --- show system info
# simulate arbitrary model
if [ -z "$X_SIMULATE_MODEL" ]; then
model="$(read_dmi product_version)"
else
model="$X_SIMULATE_MODEL"
fi
echo $model
echo "+++ System Info"
echo "System = $(read_dmi sys_vendor product_version read_dmi product_name)"
echo "System = $(read_dmi sys_vendor) $model $(read_dmi product_name)"
echo "BIOS = $(read_dmi bios_version)"

# --- show release & kernel info
Expand Down Expand Up @@ -283,6 +290,9 @@ if [ "$show_system" = "1" ] || [ "$show_all" = "1" ] ; then
1) printf "Power source = battery\n" ;;
*) printf "Power source = unknown\n" ;;
esac
if check_ac_quirk "$model"; then
echo "Notice: system may not detect AC/charger -- see: https://linrunner.de/en/tlp/docs/tlp-faq.html#acquirk"
fi
echo

# -- check systemd service units status
Expand Down Expand Up @@ -984,7 +994,7 @@ if [ "$show_warn" = "1" ] || [ "$show_disk" = "1" ] || [ "$show_all" = "1" ]; th
printf "* Kernel log shows ata errors (%d) possibly caused by the configuration\n" $ecnt
printf " SATA_LINKPWR_ON_AC/BAT=min_power or medium_power.\n"
printf " Consider using medium_power or max_performance instead.\n"
printf " See the FAQ: http://linrunner.de/en/tlp/docs/tlp-faq.html#warnings\n"
printf " See the FAQ: https://linrunner.de/en/tlp/docs/tlp-faq.html#warnings\n"
printf " Details:\n"
dmesg | grep -E -A 5 "${RE_ATA_ERROR}"
echo
Expand Down

0 comments on commit 7380f51

Please sign in to comment.