From 8210c43d83ddae43ae176a06f0f9d2a052f01953 Mon Sep 17 00:00:00 2001 From: Mystro256 Date: Mar 03 2017 02:31:17 +0000 Subject: Fix for tlp-stat --- diff --git a/tlp-stat-fix.patch b/tlp-stat-fix.patch new file mode 100644 index 0000000..dd3061d --- /dev/null +++ b/tlp-stat-fix.patch @@ -0,0 +1,64 @@ +diff --git a/tlp-stat.in b/tlp-stat.in +--- a/tlp-stat.in ++++ b/tlp-stat.in +@@ -58,6 +58,15 @@ no_runtimepm=0 + + # --- Functions + ++catparm () { # echo contents of sysfile or default if non-existent or unreadable ++ # $1: sysfile, $2: default value ++ local val="$(cat $1 2> /dev/null)" ++ [ -n "$val" ] || val="$2" # sysfile nonexistent or read failed ++ ++ printf "%s" $val ++ return 0 ++} ++ + printparm () { # formatted output of sysfile - general + # $1: format, $2: sysfile, $3: namsg, $4: cutoff + local format="$1" +@@ -1115,9 +1124,9 @@ if [ "$show_bat" = "1" ] || [ "$show_all" = "1" ]; then + echo + + # store values for charge / capacity calculation below +- ed=$(cat $batd/design_capacity) +- ef=$(cat $batd/last_full_capacity) +- en=$(cat $batd/remaining_capacity) ++ ed=$(catparm $batd/design_capacity 0) ++ ef=$(catparm $batd/last_full_capacity 0) ++ en=$(catparm $batd/remaining_capacity 0) + + # show charge + capacity + lcnt=0 +@@ -1184,9 +1193,9 @@ if [ "$show_bat" = "1" ] || [ "$show_all" = "1" ]; then + printparm "%-59s = ##%6d## [mW]" $batd/power_now "" 000 + + # store values for charge / capacity calculation below +- ed=$(cat $batd/energy_full_design) +- ef=$(cat $batd/energy_full) +- en=$(cat $batd/energy_now) ++ ed=$(catparm $batd/energy_full_design 0) ++ ef=$(catparm $batd/energy_full 0) ++ en=$(catparm $batd/energy_now 0) + + elif [ -f $batd/charge_full ]; then + printparm "%-59s = ##%6d## [mAh]" $batd/charge_full_design "" 000 +@@ -1195,9 +1204,15 @@ if [ "$show_bat" = "1" ] || [ "$show_all" = "1" ]; then + printparm "%-59s = ##%6d## [mA]" $batd/current_now "" 000 + + # store values for charge / capacity calculation below +- ed=$(cat $batd/charge_full_design) +- ef=$(cat $batd/charge_full) +- en=$(cat $batd/charge_now) ++ ed=$(catparm $batd/charge_full_design 0) ++ ef=$(catparm $batd/charge_full 0) ++ en=$(catparm $batd/charge_now 0) ++ ++ else ++ ed=0 ++ ef=0 ++ en=0 ++ + fi + if [ $tpbat -eq 1 ]; then + print_tp_batstate $batd/status diff --git a/tlp.spec b/tlp.spec index 9b3463f..af0d22c 100644 --- a/tlp.spec +++ b/tlp.spec @@ -1,6 +1,6 @@ Name: tlp Version: 0.9 -Release: 3%{?dist} +Release: 4%{?dist} Summary: Advanced power management tool for Linux License: GPLv2+ URL: http://linrunner.de/tlp @@ -8,6 +8,10 @@ Source0: https://github.com/linrunner/TLP/archive/%{version}.tar.gz #Provided by Andreas Roederer : Source1: 50-tlp.preset +#Cherry-pick upstream fix to tlp-stat: +#https://github.com/linrunner/TLP/commit/9498a85d1cedb78a38b54f243c9c4a3daad5bcc6 +Patch0: tlp-stat-fix.patch + BuildRequires: perl-generators BuildRequires: systemd @@ -99,6 +103,9 @@ fi /bin/systemctl enable NetworkManager-dispatcher.service >/dev/null 2>&1 || : %changelog +* Thu Mar 02 2017 Jeremy Newton - 0.9-4 +- Cherry-pick upstream fix for tlp-stat + * Sat Feb 11 2017 Fedora Release Engineering - 0.9-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild