Hello community,

here is the log from the commit of package tlp for openSUSE:Factory checked in 
at 2019-05-24 11:30:49
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/tlp (Old)
 and      /work/SRC/openSUSE:Factory/.tlp.new.5148 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "tlp"

Fri May 24 11:30:49 2019 rev:12 rq:704782 version:1.2.2

Changes:
--------
--- /work/SRC/openSUSE:Factory/tlp/tlp.changes  2019-03-19 10:02:52.515808860 
+0100
+++ /work/SRC/openSUSE:Factory/.tlp.new.5148/tlp.changes        2019-05-24 
11:30:51.689414557 +0200
@@ -1,0 +2,24 @@
+Sun May 19 14:35:37 UTC 2019 - Alexei Sorokin <sor.ale...@meowr.ru>
+
+- Update to version 1.2.2:
+  * Battery Features, tlp-stat -b:
+    - Show data for batteries named other than BAT0/BAT1
+      (non-ThinkPads).
+    - ThinkPad X1C6 discharge malfunction (gh#linrunner/TLP#395).
+    - Separate checks for charge thresholds and recalibration.
+    - Intelligible recommendation for tp-smapi on
+      ThinkPad X220/T420 et al.
+    - Explain "Battery Features: Charge Thresholds and Recalibrate".
+  * Discs:
+    - Fix type determination.
+  * Operation Mode AC/BAT:
+    - MacBookPro 5.3: Workaround for false AC offline status.
+  * Processor, tlp-stat -p:
+    - Fix read of /sys/devices/system/cpu/cpufreq/boost.
+    - x86_energy_perf_policy: Detect unsupported CPUs in newer
+      versions.
+  * Radio Devices:
+    - Make RESTORE_DEVICE_STATE_ON_STARTUP=1 persistent again
+      (gh#linrunner/TLP#404).
+
+-------------------------------------------------------------------

Old:
----
  TLP-1.2.1.tar.gz

New:
----
  TLP-1.2.2.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ tlp.spec ++++++
--- /var/tmp/diff_new_pack.FQ0duD/_old  2019-05-24 11:30:52.577414329 +0200
+++ /var/tmp/diff_new_pack.FQ0duD/_new  2019-05-24 11:30:52.581414328 +0200
@@ -18,7 +18,7 @@
 
 %define _name   TLP
 Name:           tlp
-Version:        1.2.1
+Version:        1.2.2
 Release:        0
 Summary:        Save battery power on laptops
 License:        GPL-2.0-or-later AND GPL-3.0-or-later
@@ -116,6 +116,7 @@
 %dir %{_libexecdir}/udev/rules.d/
 %{_libexecdir}/udev/%{name}-usb-udev
 %{_libexecdir}/udev/rules.d/85-%{name}.rules
+%{_localstatedir}/lib/%{name}/
 %dir %{_datadir}/bash-completion/
 %dir %{_datadir}/bash-completion/completions/
 %{_datadir}/bash-completion/completions/bluetooth

++++++ TLP-1.2.1.tar.gz -> TLP-1.2.2.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/TLP-1.2.1/.github/Bug_Reporting_Howto.md 
new/TLP-1.2.2/.github/Bug_Reporting_Howto.md
--- old/TLP-1.2.1/.github/Bug_Reporting_Howto.md        2019-03-18 
18:08:25.000000000 +0100
+++ new/TLP-1.2.2/.github/Bug_Reporting_Howto.md        2019-05-04 
19:49:18.000000000 +0200
@@ -6,11 +6,13 @@
 * Followed the appropiate [Installation 
instructions](https://linrunner.de/en/tlp/docs/tlp-linux-advanced-power-management.html#installation)
 * Read the [Settings 
guide](https://linrunner.de/en/tlp/docs/tlp-configuration.html)
 * Carefully checked the [FAQ](https://linrunner.de/en/tlp/docs/tlp-faq.html)
+* Checked [existing bug reports](https://github.com/linrunner/TLP/issues)
 * Tried to isolate the cause as described in 
[Troubleshooting](https://linrunner.de/en/tlp/docs/tlp-troubleshooting.html)
 
 ### What not to report
 * Missing packages (including tp-smapi and acpi_call)
 * Asking for help about installation, configuration and usage
+* Questions about your laptop's power consumption and how to optimize it
 * Deviations from powertop's recommendations
 * Hardware issues e.g. worn out or malfunctioning batteries
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/TLP-1.2.1/.github/ISSUE_TEMPLATE/bug_report.md 
new/TLP-1.2.2/.github/ISSUE_TEMPLATE/bug_report.md
--- old/TLP-1.2.1/.github/ISSUE_TEMPLATE/bug_report.md  2019-03-18 
18:08:25.000000000 +0100
+++ new/TLP-1.2.2/.github/ISSUE_TEMPLATE/bug_report.md  2019-05-04 
19:49:18.000000000 +0200
@@ -24,7 +24,8 @@
 1. Does the problem occur on battery or AC or both?
 2. Actions to reproduce the behaviour
 3. Shell commands entered and their output
-4. **Full output of `tlp-stat` via https://gist.github.com/ for *all* cases of 
1**
+4. **Full output of `tlp-stat` via https://gist.github.com/ for *all*
+   matching cases of 1.**
 
 **Additional context**
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/TLP-1.2.1/Makefile new/TLP-1.2.2/Makefile
--- old/TLP-1.2.1/Makefile      2019-03-18 18:08:25.000000000 +0100
+++ new/TLP-1.2.2/Makefile      2019-05-04 19:49:18.000000000 +0200
@@ -15,6 +15,7 @@
 TLP_MAN    ?= /usr/share/man
 TLP_META   ?= /usr/share/metainfo
 TLP_RUN    ?= /run/tlp
+TLP_VAR    ?= /var/lib/tlp
 
 # Catenate DESTDIR to paths
 _SBIN  = $(DESTDIR)$(TLP_SBIN)
@@ -31,6 +32,7 @@
 _MAN   = $(DESTDIR)$(TLP_MAN)
 _META  = $(DESTDIR)$(TLP_META)
 _RUN   = $(DESTDIR)$(TLP_RUN)
+_VAR   = $(DESTDIR)$(TLP_VAR)
 
 SED = sed \
        -e "s|@TLP_SBIN@|$(TLP_SBIN)|g" \
@@ -38,7 +40,8 @@
        -e "s|@TLP_FLIB@|$(TLP_FLIB)|g" \
        -e "s|@TLP_ULIB@|$(TLP_ULIB)|g" \
        -e "s|@TLP_CONF@|$(TLP_CONF)|g" \
-       -e "s|@TLP_RUN@|$(TLP_RUN)|g"
+       -e "s|@TLP_RUN@|$(TLP_RUN)|g"   \
+       -e "s|@TLP_VAR@|$(TLP_VAR)|g"
 
 INFILES = \
        tlp \
@@ -117,11 +120,11 @@
 ifneq ($(TLP_NO_INIT),1)
        install -D -m 755 tlp.init $(_SYSV)/tlp
 endif
-ifeq ($(TLP_WITH_SYSTEMD),1)
+ifneq ($(TLP_WITH_SYSTEMD),0)
        install -D -m 644 tlp.service $(_SYSD)/tlp.service
        install -m 644 tlp-sleep.service $(_SYSD)/
 endif
-ifeq ($(TLP_WITH_ELOGIND),1)
+ifneq ($(TLP_WITH_ELOGIND),0)
        install -D -m 755 tlp-sleep.elogind $(_ELOD)/49-tlp-sleep
 endif
 ifneq ($(TLP_NO_BASHCOMP),1)
@@ -132,6 +135,7 @@
        ln -sf tlp $(_SHCPL)/wwan
 endif
        install -D -m 644 de.linrunner.tlp.metainfo.xml 
$(_META)/de.linrunner.tlp.metainfo.xml
+       install -d -m 755 $(_VAR)
 
 install-rdw: all
        # Package tlp-rdw
@@ -171,7 +175,7 @@
        rm -r $(_TLIB)
        rm $(_ULIB)/tlp-usb-udev
        rm $(_ULIB)/rules.d/85-tlp.rules
-       rm -f $(DESTDIR)/etc/init.d/tlp
+       rm -f $(_SYSV)/tlp
        rm -f $(_SYSD)/tlp.service
        rm -f $(_SYSD)/tlp-sleep.service
        rm -f $(_ELOD)/49-tlp-sleep
@@ -181,6 +185,7 @@
        rm -f $(_SHCPL)/wwan
        rm -f $(_SHCPL)/tlp
        rm -f $(_META)/de.linrunner.tlp.metainfo.xml
+       rm -r $(_VAR)
 
 uninstall-rdw:
        # Package tlp-rdw
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/TLP-1.2.1/changelog new/TLP-1.2.2/changelog
--- old/TLP-1.2.1/changelog     2019-03-18 18:08:25.000000000 +0100
+++ new/TLP-1.2.2/changelog     2019-05-04 19:49:18.000000000 +0200
@@ -1,3 +1,22 @@
++++ 1.2.2 --- 04.05.2019 +++
+
+  * Bugfixes
+    Battery Features, tlp-stat -b:
+      - Show data for batteries named other than BAT0/BAT1 (non-ThinkPads)
+      - Issue #395: ThinkPad X1C6 discharge malfunction
+      - Separate checks for charge thresholds and recalibration
+      - Intelligible recommendation for tp-smapi on ThinkPad X220/T420 et al.
+      - Explain "Battery Features: Charge Thresholds and Recalibrate"
+    Disks:
+      - Fix type determination
+    Operation Mode AC/BAT:
+      - MacBookPro 5.3: workaround for false AC offline status
+    Processor, tlp-stat -p:
+      - Fix read of /sys/devices/system/cpu/cpufreq/boost
+      - x86_energy_perf_policy: detect unsupported CPUs in newer versions
+    Radio Devices:
+      - Issue #404: make RESTORE_DEVICE_STATE_ON_STARTUP=1 persistent again
+
 +++ 1.2.1 --- 18.03.2019 +++
 
   * Bugfix
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/TLP-1.2.1/func.d/15-tlp-func-disk 
new/TLP-1.2.2/func.d/15-tlp-func-disk
--- old/TLP-1.2.1/func.d/15-tlp-func-disk       2019-03-18 18:08:25.000000000 
+0100
+++ new/TLP-1.2.2/func.d/15-tlp-func-disk       2019-05-04 19:49:18.000000000 
+0200
@@ -32,7 +32,7 @@
 get_disk_dev () { # translate disk id to device (sdX)
     # $1: id or dev;
     # retval: $_disk_dev, $_disk_id, $_disk_type
-    local path
+    local bus path
 
     if [ -h /dev/disk/by-id/$1 ]; then
         # $1 is disk id
@@ -48,15 +48,22 @@
 
     # determine device type (bus)
     if [ -b /dev/$_disk_dev ]; then
-        path="$($UDEVADM info -n "$_disk_dev" -q property 2>/dev/null | sed -n 
's/^ID_PATH=//p')"
+        path="$($UDEVADM info -q property /dev/$_disk_dev 2>/dev/null | sed -n 
's/^ID_PATH=//p')"
+        bus="$($UDEVADM  info -q property /dev/$_disk_dev 2>/dev/null | sed -n 
's/^ID_BUS=//p')"
         case "$path" in
             pci-*-nvme-*)     _disk_type="nvme" ;;
             pci-*-ata-*)      _disk_type="ata"  ;;
             pci-*-usb-*)      _disk_type="usb"  ;;
             pci-*-ieee1394-*) _disk_type="ieee1394" ;;
-            *)                _disk_type="unknown" ;;
+            *) case "$bus" in
+                nvme)      _disk_type="nvme" ;;
+                ata)       _disk_type="ata"  ;;
+                usb)       _disk_type="usb"  ;;
+                ieee1394)  _disk_type="ieee1394" ;;
+                *)         _disk_type="unknown" ;;
+            esac
         esac
-        echo_debug "disk" "get_disk_dev($1): dev=$_disk_dev; type=$_disk_type; 
path=$path"
+        echo_debug "disk" "get_disk_dev($1): dev=$_disk_dev; type=$_disk_type; 
path=$path; bus=$bus"
     else
         _disk_type="none"
         echo_debug "disk" "get_disk_dev($1).missing"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/TLP-1.2.1/func.d/30-tlp-func-rf-sw 
new/TLP-1.2.2/func.d/30-tlp-func-rf-sw
--- old/TLP-1.2.1/func.d/30-tlp-func-rf-sw      2019-03-18 18:08:25.000000000 
+0100
+++ new/TLP-1.2.2/func.d/30-tlp-func-rf-sw      2019-05-04 19:49:18.000000000 
+0200
@@ -22,6 +22,8 @@
 readonly RDW_LOCKTIME=2
 readonly RDW_KILL="rdw_kill"
 
+readonly RFSTATEFILE=$VARDIR/rfkill_saved
+
 readonly DEFAULT_RESTORE_DEVICE_STATE_ON_STARTUP=0
 
 # ----------------------------------------------------------------------------
@@ -118,7 +120,6 @@
 }
 
 check_nm () { # test if NetworkManager is running and nmcli is installed
-
     cmd_exists $NMCLI
 }
 
@@ -332,28 +333,31 @@
 
 # shellcheck disable=SC2120
 save_device_states () { # save radio states -- $1: list of rftypes
+                        # rc: 0=ok/1=create failed/2=write failed
     local dev
     local devlist="${1:-$ALLDEV}" # when arg empty -> use all
-
-    echo_debug "rf" "save_device_states($devlist): $RFSTATEFILE"
+    local rc=0
 
     # create empty state file
-    create_rundir
-    { : > $RFSTATEFILE; } 2> /dev/null
-
-    # iterate over all possible devices -> save state in file
-    for dev in $devlist; do
-        device_state $dev
-        { printf '%s\n' "$dev $_devs" >> $RFSTATEFILE; } 2> /dev/null
-    done
+    if { : > $RFSTATEFILE; } 2> /dev/null; then
+        # iterate over all possible devices -> save state in file
+        for dev in $devlist; do
+            device_state $dev
+            { printf '%s\n' "$dev $_devs" >> $RFSTATEFILE; } 2> /dev/null || 
rc=2
+        done
+    else
+        # create failed
+        rc=1
+    fi
 
-    return 0
+    echo_debug "rf" "save_device_states($devlist): $RFSTATEFILE; rc=$rc"
+    return $rc
 }
 
 restore_device_states () { # restore radio type states
+                           # rc: 0=ok/1=state file nonexistent
     local sline
-
-    echo_debug "rf" "restore_device_states: $RFSTATEFILE"
+    local rc=0
 
     if [ -f $RFSTATEFILE ]; then
         # read state file
@@ -362,11 +366,13 @@
             set -- $sline # read dev, state into $1, $2
             device_switch $1 $2
         done < $RFSTATEFILE
-
-        return 0
     else
-        return 1
+        # state file nonexistent
+        rc=1
     fi
+
+    echo_debug "rf" "restore_device_states: $RFSTATEFILE; rc=$rc"
+    return $rc
 }
 
 set_radio_device_states () { # set/initialize all radio states
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/TLP-1.2.1/func.d/35-tlp-func-batt 
new/TLP-1.2.2/func.d/35-tlp-func-batt
--- old/TLP-1.2.1/func.d/35-tlp-func-batt       2019-03-18 18:08:25.000000000 
+0100
+++ new/TLP-1.2.2/func.d/35-tlp-func-batt       2019-05-04 19:49:18.000000000 
+0200
@@ -192,9 +192,9 @@
 # --- Battery Detection
 
 battery_present () { # check battery presence and return tpacpi-bat index
-    # $1: BAT0/BAT1/DEF
+    # $1: BAT0/BAT1/DEF/other
     # global param: $_bm_read
-    # rc: 0=bat exists/1=bat nonexistent/255=no method available
+    # rc: 0=bat exists/1=bat nonexistent
     # retval: $_bat_str:   BAT0/BAT1;
     #         $_bat_idx:   1/2;
     #         $_bd_read:   directory with battery data sysfiles;
@@ -203,7 +203,7 @@
     #         $_bf_dischg: sysfile for force discharge
 
     # defaults
-    local rc=255  # no threshold API available
+    local rc=1    # bat nonexistent
     _bat_idx=0    # no index
     _bat_str=""   # no bat
     _bd_read=""   # no directories
@@ -218,14 +218,12 @@
 
     # validate param
     case $1 in
-        BAT0|BAT1) blist="$1" ;;
-        DEF)       blist="BAT0 BAT1" ;;
-        *)         return 1 ;;
+        DEF) blist="BAT0 BAT1" ;;
+        *)   blist="$1" ;;
     esac
 
     case $_bm_read in
         natacpi) # note: includes tpacpi
-            rc=1
             for bs in $blist; do
                 bsd="$ACPIBATDIR/$bs"
 
@@ -250,6 +248,11 @@
                                 _bat_idx=1 # BAT0 nonexistent --> BAT1 is main
                             fi
                             ;;
+
+                        *) # non-featured battery --> data read only
+                            _bat_str="$bs"
+                            _bd_read="$bsd"
+                            ;;
                     esac
                     break # exit loop on first battery detected
                 fi
@@ -295,7 +298,6 @@
     case $rc in
         0)   echo_debug "bat" "battery_present($1): bm_read=$_bm_read; 
bat_str=$_bat_str; bat_idx=$_bat_idx; bd_read=$_bd_read; bf_start=$_bf_start; 
bf_stop=$_bf_stop; bf_dischg=$_bf_dischg; rc=$rc" ;;
         1)   echo_debug "bat" "battery_present($1).not_detected: 
bm_read=$_bm_read; rc=$rc" ;;
-        255) echo_debug "bat" "battery_present($1).no_api" ;;
     esac
 
     return $rc
@@ -597,6 +599,13 @@
     battery_present $bat
     case $? in
         0) # battery present
+            if [ "$_bm_thresh" = "none" ]; then
+                # no method available --> quit
+                echo "Error: battery charge thresholds not available." 1>&2
+                echo_debug "bat" "setcharge_battery.no_method"
+                return 1
+            fi
+
             # get configured values if requested
             if [ $use_cfg -eq 1 ]; then
                 eval start_thresh="\$START_CHARGE_THRESH_${_bat_str}"
@@ -604,12 +613,6 @@
             fi
             ;;
 
-        255) # no method
-            echo "Error: battery feature not available." 1>&2
-            echo_debug "bat" "setcharge_battery.no_method"
-            return 1
-            ;;
-
         *) # not present
             echo "Error: battery $bat not present." 1>&2
             echo_debug "bat" "setcharge_battery.not_present($bat)"
@@ -661,12 +664,13 @@
     # check if selected battery is present
     battery_present $bat
     case $? in
-        0) ;; # battery present
-
-        255) # no method
-            echo "Error: battery feature not available." 1>&2
-            echo_debug "bat" "chargeonce_battery.no_method"
-            return 1
+        0) # battery present
+            if [ "$_bm_thresh" = "none" ]; then
+                # no method available --> quit
+                echo "Error: battery charge thresholds not available." 1>&2
+                echo_debug "bat" "chargeonce_battery.no_method"
+                return 1
+            fi
             ;;
 
         *) # not present
@@ -859,12 +863,13 @@
     # check if selected battery is present
     battery_present $bat
     case $? in
-        0) ;; # battery present
-
-        255) # no method
-            echo "Error: battery feature not available." 1>&2
-            echo_debug "bat" "discharge_battery.no_method"
-            return 1
+        0) # battery present
+            if [ "$_bm_dischg" = "none" ]; then
+                # no method available --> quit
+                echo "Error: battery discharge/recalibrate not available." 1>&2
+                echo_debug "bat" "discharge_battery.no_method"
+                return 1
+            fi
             ;;
 
         *) # not present
@@ -877,16 +882,22 @@
     # start discharge
     set_force_discharge $_bat_str 1; rc=$?
     if [ $rc -ne 0 ]; then
-        echo_debug "bat" 
"discharge_battery.force_discharge_not_available($_bat_str)"
-        echo "Error: discharge function not available for this laptop." 1>&2
+        echo_debug "bat" 
"discharge_battery.force_discharge_malfunction($_bat_str)"
+        echo "Error: discharge malfunction." 1>&2
         return 1
     fi
 
     trap cancel_force_discharge INT # enable ^C hook
 
-    # wait for start == while status not "discharging" -- 5.0 sec timeout
-    wt=10
-    while ! battery_discharging $_bat_str && [ $wt -gt 0 ] ; do sleep 0.5; 
wt=$((wt - 1)); done
+    # wait for start == while status not "discharging" -- 15.0 sec timeout
+    printf "Initiating discharge of battery %s " $_bat_str
+    wt=15
+    while ! battery_discharging $_bat_str && [ $wt -gt 0 ] ; do
+        sleep 1
+        printf "."
+        wt=$((wt - 1))
+    done
+    printf "\n"
 
     if battery_discharging $_bat_str; then
         # discharge initiated sucessfully --> wait for completion == while 
status "discharging"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/TLP-1.2.1/func.d/40-tlp-func-bay 
new/TLP-1.2.2/func.d/40-tlp-func-bay
--- old/TLP-1.2.1/func.d/40-tlp-func-bay        2019-03-18 18:08:25.000000000 
+0100
+++ new/TLP-1.2.2/func.d/40-tlp-func-bay        2019-05-04 19:49:18.000000000 
+0200
@@ -13,7 +13,6 @@
 
 readonly DOCKGLOB="/sys/devices/platform/dock.?"
 
-readonly RFSTATEFILE=$RUNDIR/rfkill_saved
 readonly BAYSTATEFILE=$RUNDIR/bay_saved
 
 readonly DEFAULT_BAY_POWEROFF_ON_AC=0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/TLP-1.2.1/func.d/tlp-func-stat 
new/TLP-1.2.2/func.d/tlp-func-stat
--- old/TLP-1.2.1/func.d/tlp-func-stat  2019-03-18 18:08:25.000000000 +0100
+++ new/TLP-1.2.2/func.d/tlp-func-stat  2019-05-04 19:49:18.000000000 +0200
@@ -207,8 +207,8 @@
 
     if [ -z "$model" ]; then
         # hdparm -I not supported --> try udevadm approach
-        vendor="$($UDEVADM info -n /dev/$1 -q property 2>/dev/null | sed -n 
's/^ID_VENDOR=//p')"
-        model="$( $UDEVADM info -n /dev/$1 -q property 2>/dev/null | sed -n 
's/^ID_MODEL=//p' )"
+        vendor="$($UDEVADM info -q property /dev/$1 2>/dev/null | sed -n 
's/^ID_VENDOR=//p')"
+        model="$( $UDEVADM info -q property /dev/$1 2>/dev/null | sed -n 
's/^ID_MODEL=//p' )"
         model=$(printf "%s %s" "$vendor" "$model" | sed -r 's/_/ /g; s/-//g; 
s/[[:space:]]+$//')
     fi
 
@@ -467,7 +467,7 @@
             case $bm in
                 _bm_read)   m="data" ;;
                 _bm_thresh) m="thresholds" ;;
-                _bm_dischg) m="discharge" ;;
+                _bm_dischg) m="recalibrate" ;;
             esac
             # concat method to output
             if [ -n "$mlist" ]; then
@@ -527,6 +527,8 @@
     # global param: $_bm_thresh, $_bat_idx, $_bf_start, $_bf_stop
     local bsys sp thresh
 
+    [ "$_bm_thresh" != "none" ] || return 0 # no method available --> quit
+
     for sp in start stop; do
         get_threshold $sp; thresh=$?
 
@@ -572,6 +574,8 @@
     # global param: $_bm_dischg, $_bat_idx, $_bf_dischg
     local force
 
+    [ "$_bm_dischg" != "none" ] || return 0 # no method available --> quit
+
     get_force_discharge $1; force=$?
 
     if [ $force -lt 2 ]; then
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/TLP-1.2.1/man/tlp.8 new/TLP-1.2.2/man/tlp.8
--- old/TLP-1.2.1/man/tlp.8     2019-03-18 18:08:25.000000000 +0100
+++ new/TLP-1.2.2/man/tlp.8     2019-05-04 19:49:18.000000000 +0200
@@ -71,10 +71,6 @@
 battery and recharge to 100%.
 .
 .TP
-.B stat
-Same as tlp\-stat.
-.
-.TP
 .B diskid
 Show disk ids for configuration.
 .
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/TLP-1.2.1/tlp-func-base.in 
new/TLP-1.2.2/tlp-func-base.in
--- old/TLP-1.2.1/tlp-func-base.in      2019-03-18 18:08:25.000000000 +0100
+++ new/TLP-1.2.2/tlp-func-base.in      2019-05-04 19:49:18.000000000 +0200
@@ -9,10 +9,11 @@
 # ----------------------------------------------------------------------------
 # Constants
 
-readonly TLPVER="1.2.1"
+readonly TLPVER="1.2.2"
 
 readonly CONFFILE=@TLP_CONF@
 readonly RUNDIR=@TLP_RUN@
+readonly VARDIR=@TLP_VAR@
 
 readonly FLOCK=flock
 readonly HDPARM=hdparm
@@ -476,6 +477,9 @@
             # it's a real ThinkPad --> save model substring
             _tpmodel=$(echo $pv | sed -r 's/^Think[Pp]ad //')
         fi
+    else
+        # not a ThinkPad: get DMI product string
+        pv="$(read_dmi product_version)"
     fi
 
     if [ -n "$_tpmodel" ]; then
@@ -514,11 +518,10 @@
     #           +------------ +------+------+------+
     # battery   | none        | 2    | 0    | 1    |
     # status:   | discharging | 1    | 0    | 1    |
-    #           | idle        | 0    | 0    | 1    |
-    #
-    # Note: existing AC online status has precendence over any battery status
+    #           | idle        | 0    | 0    | 0    |
 
     local psrc
+    local ac0seen=
     _syspwr=
 
     for psrc in /sys/class/power_supply/*; do
@@ -531,26 +534,29 @@
             Mains|USB)
                 # AC detected
                 # skip device to simulate broken AC detection
-                [ "$X_SIMULATE_AC_QUIRK" = "1" ] && continue
+                [ "$X_SIMULATE_AC_QUIRK" = "2" ] && continue
 
                 # check if online
                 if [ "$(read_sysf $psrc/online)" = "1" ]; then
-                    # AC online
+                    # AC online --> end iteration
                     _syspwr=0
                     echo_debug "ps" 
"get_sys_power_supply(${psrc##/*/}).ac_online: syspwr=$_syspwr"
+                    break
                 else
-                    # AC offline means battery
-                    _syspwr=1
-                    echo_debug "ps" 
"get_sys_power_supply(${psrc##/*/}).ac_offline: syspwr=$_syspwr"
+                    # AC offline could mean battery, but quirky hardware exists
+                    # --> just remember and continue to look for batteries
+                    ac0seen=$psrc
                 fi
-                break # AC found --> end search
                 ;;
 
             Battery)
                 # battery detected
-                # --> inspect unless discharging battery has been found 
beforehand
+                # --> inspect unless a discharging battery has been found 
beforehand
                 [ "$_syspwr" = "1" ] && continue
 
+                # skip device to simulate broken battery detection
+                [ "$X_SIMULATE_BAT_QUIRK" = "2" ] && continue
+
                 case "$(read_sysf $psrc/status)" in
                     Discharging)
                         if ! lockpeek_tlp tlp_discharge; then
@@ -587,10 +593,17 @@
         esac
     done
 
-    # set _syspwr to unknown if we haven't seen any AC/battery power source so 
far
     if [ -z "$_syspwr" ]; then
-        _syspwr=2
-        echo_debug "ps" "get_sys_power_supply.unknown: syspwr=$_syspwr"
+        # _syspwr result yet undecided
+        if [ -n "$ac0seen" ]; then
+            # no battery seen but AC offline remembered --> battery
+            _syspwr=1
+            echo_debug "ps" "get_sys_power_supply(${ac0seen##/*/}).ac_offline: 
syspwr=$_syspwr"
+        else
+            # we haven't seen any AC/battery power source --> unknown
+            _syspwr=2
+            echo_debug "ps" "get_sys_power_supply.unknown: syspwr=$_syspwr"
+        fi
     fi
 
     return $_syspwr
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/TLP-1.2.1/tlp-stat.in new/TLP-1.2.2/tlp-stat.in
--- old/TLP-1.2.1/tlp-stat.in   2019-03-18 18:08:25.000000000 +0100
+++ new/TLP-1.2.2/tlp-stat.in   2019-05-04 19:49:18.000000000 +0200
@@ -381,7 +381,7 @@
 
     elif [ -f $CPU_BOOST_ALL_CTRL ]; then
         # show turbo boost info
-        get_sysval $CPU_BOOST_ALL_CTRL; boost=$?
+        boost=$(read_sysval $CPU_BOOST_ALL_CTRL)
 
         # simple test for attribute "w" doesn't work, so actually write
         if write_sysf "$boost" $CPU_BOOST_ALL_CTRL; then
@@ -403,27 +403,32 @@
     # --- show x86 energy perf policy info
     if cmd_exists $ENERGYPERF; then
         # check CPU support
-        $ENERGYPERF -r > /dev/null 2>&1
+        eperf=$($ENERGYPERF -r 2> /dev/null)
         case $? in
-            0)  # parse x86_energy_perf_policy output:
-                # - replace numbers with descriptive strings
-                # - remove ":"
-                # - indent and align
-                $ENERGYPERF -r 2>/dev/null | grep -v 'HWP_' | \
-                    sed -r 's/://;
-                            s/(0x0000000000000000|EPB 0)/performance/;
-                            s/(0x0000000000000004|EPB 4)/balance-performance/;
-                            s/(0x0000000000000006|EPB 6)/default/;
-                            s/(0x0000000000000008|EPB 8)/balance-power/;
-                            s/(0x000000000000000f|EPB 15)/power/' | \
-                    awk '{ printf "x86_energy_perf_policy.%-31s = %s %s\n", 
$1, $2, $3; }'
+            0)  if [ -n "$eperf" ]; then
+                    # parse x86_energy_perf_policy output:
+                    # - replace numbers with descriptive strings
+                    # - remove ":"
+                    # - indent and align
+                    $ENERGYPERF -r 2>/dev/null | grep -v 'HWP_' | \
+                        sed -r 's/://;
+                                s/(0x0000000000000000|EPB 0)/performance/;
+                                s/(0x0000000000000004|EPB 
4)/balance-performance/;
+                                s/(0x0000000000000006|EPB 6)/default/;
+                                s/(0x0000000000000008|EPB 8)/balance-power/;
+                                s/(0x000000000000000f|EPB 15)/power/' | \
+                        awk '{ printf "x86_energy_perf_policy.%-31s = %s 
%s\n", $1, $2, $3; }'
+                    printf "\n"
+                else
+                    # newer versions produce zero output for unsupported CPUs
+                    printf "x86_energy_perf_policy: unsupported CPU.\n\n"
+                fi
                 ;;
 
-            1) echo "x86_energy_perf_policy: unsupported CPU." ;;
-            2) echo "x86_energy_perf_policy: program for your kernel not 
installed." ;;
-            *) echo "x86_energy_perf_policy: not available." ;;
+            1) printf "x86_energy_perf_policy: unsupported CPU.\n\n" ;;
+            2) printf "x86_energy_perf_policy: program for your kernel not 
installed.\n\n" ;;
+            *) printf "x86_energy_perf_policy: not available.\n\n" ;;
         esac
-        echo
     else
         echo "x86_energy_perf_policy: program not installed."
         echo
@@ -808,7 +813,7 @@
     ensum=0
 
     # --- show availability of (ThinkPad) battery features
-    echo "+++ Battery Features"
+    echo "+++ Battery Features: Charge Thresholds and Recalibrate"
 
     # native ACPI kernel battery API
     case $_natacpi in
@@ -864,8 +869,8 @@
                 0) echo "+++ ThinkPad Battery Status: $batt" ;;
             esac
         else
-            # laptop or ThinkPad without feature support
-            echo "+++ Battery Status"
+            #  non-featured ThinkPad or other laptop make
+            echo "+++ Battery Status: $batt"
         fi
 
         case $_bm_read in
@@ -989,7 +994,7 @@
     if [ $bcnt -eq 0 ]; then
         # no battery detected
         printf "+++ Battery Status\n"
-        printf "No batteries detected.\n\n"
+        printf "No battery data available.\n\n"
     elif [ $bcnt -gt 1 ] && [ $efsum -ne 0 ]; then
         # more than one battery detected --> show charge total
         perl -e 'printf ("%-59s = %6.1f [%%]\n", "+++ Charge total",   100.0 * 
'$ensum' / '$efsum');'
@@ -1028,8 +1033,13 @@
 
     if is_thinkpad; then
         # add ThinkPad specific recommendations
-        [ $_tpsmapi -eq 128 ] \
-            && reout="${reout}Install tp-smapi kernel modules for ThinkPad 
battery thresholds and recalibration\n"
+        if [ $_tpsmapi -eq 128 ]; then
+            if supports_tpsmapi_and_tpacpi; then
+                reout="${reout}Install tp-smapi kernel modules for extended 
battery info (e.g. the cycle count)\n"
+            else
+                reout="${reout}Install tp-smapi kernel modules for ThinkPad 
battery thresholds and recalibration\n"
+            fi
+        fi
         case $_tpacpi in
             127) missing="tpacpi-bat program" ;;
             128) missing="acpi_call kernel module" ;;
@@ -1053,6 +1063,7 @@
     if [ -n "$reout" ]; then
         echo "+++ Recommendations"
         # shellcheck disable=SC2059
+        # don't change to %s, $reout contains blanks and \n!
         printf "$reout" | sed -r 's/^/\* /'
         echo
     fi
@@ -1086,7 +1097,13 @@
     jdone=0
     if cmd_exists $JOURNALCTL; then
         # retrieve trace output from journal, rc=1 if journald has no data 
available
-        $JOURNALCTL -p debug --no-pager SYSLOG_IDENTIFIER=tlp 2> /dev/null && 
jdone=1
+        if [ $show_verbose -eq 1 ]; then
+            # verbose: show all output
+            $JOURNALCTL -p debug --no-pager SYSLOG_IDENTIFIER=tlp 2> /dev/null 
&& jdone=1
+        else
+            # non-verbose: show output since last reboot only
+            $JOURNALCTL -p debug --no-pager SYSLOG_IDENTIFIER=tlp -b 2> 
/dev/null && jdone=1
+        fi
     fi
 
     if [ "$jdone" = "0"  ]; then
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/TLP-1.2.1/tlp.bash_completion 
new/TLP-1.2.2/tlp.bash_completion
--- old/TLP-1.2.1/tlp.bash_completion   2019-03-18 18:08:25.000000000 +0100
+++ new/TLP-1.2.2/tlp.bash_completion   2019-05-04 19:49:18.000000000 +0200
@@ -5,8 +5,9 @@
     local bats b
 
     bats=$( {
-        for b in /sys/class/power_supply/BAT*; do
-            if [ $(cat $b/present 2> /dev/null) = "1" ]; then
+        for b in /sys/class/power_supply/*; do
+            if [ "$(cat $b/present 2> /dev/null)" = "1" ] \
+                   && [ "$(cat $b/type)" = "Battery" ]; then
                 echo "${b##/*/} "
             fi
         done } )
@@ -67,8 +68,8 @@
     local cur prev words cword opts
     _init_completion || return
 
-    opts="--battery --config --disk --pcie --pev --psup --processor --rfkill
-          --system --temp --usb --warn --trace --verbose"
+    opts="--battery --config --disk --graphics --pcie --pev --psup --processor
+          --rfkill --system --temp --usb --warn --trace --verbose"
 
     if [ $cword -eq 1 ]; then
         COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )


Reply via email to