Skip to content

Commit

Permalink
Speed up power source detection
Browse files Browse the repository at this point in the history
Remove delayed battery state re-check. There is no evidence
that it really helps and there is TLP_PS_IGNORE anyway.
  • Loading branch information
linrunner committed Nov 1, 2020
1 parent 739fb91 commit 345674a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
3 changes: 3 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
- tlp-stat -g:
- Show hybrid graphics switch state (switcheroo)
- List all GPUs with at least the driver info
Operation Mode AC/BAT:
- Speed up power source detection (obsolete delayed battery state check
removed)
PCI(e) devices:
- RUNTIME_PM_ENABLE/DISABLE: permanently enable/disable runtime PM for
PCI(e) devices based on address (independent of the power source)
Expand Down
21 changes: 4 additions & 17 deletions tlp-func-base.in
Original file line number Diff line number Diff line change
Expand Up @@ -592,23 +592,10 @@ get_sys_power_supply () { # get current power supply
break # --> end iteration
;;

*) # everything else - e.g. "Charging", "Full", "Unknown" - might be caused by lagging
# battery status updates --> re-check after a short delay
echo_debug "ps" "get_sys_power_supply(${psrc_name}).bat_not_discharging_check1: bs=$bs; syspwr=$_syspwr"
sleep 0.8
bs="$(read_sysf $psrc/status)"
if [ "$bs" = "Discharging" ] && ! lockpeek_tlp tlp_discharge; then
# battery status changed to "Discharging" (not forced) means battery mode
# --> end iteration
_syspwr=1
echo_debug "ps" "get_sys_power_supply(${psrc_name}).bat_discharging_check2: bs=$bs; syspwr=$_syspwr"
break
else
# otherwise assume AC mode
# --> continue looking
_syspwr=0
echo_debug "ps" "get_sys_power_supply(${psrc_name}).bat_not_discharging_check2: bs=$bs; syspwr=$_syspwr"
fi
*) # assume AC mode for everything else - e.g. "Charging", "Full", "Unknown"
# --> continue looking
_syspwr=0
echo_debug "ps" "get_sys_power_supply(${psrc_name}).bat_not_discharging: bs=$bs; syspwr=$_syspwr"
;;

esac
Expand Down

0 comments on commit 345674a

Please sign in to comment.