Skip to content

Commit

Permalink
bash completion: suggest stop threshold as target level for tlp dicharge
Browse files Browse the repository at this point in the history
  • Loading branch information
linrunner committed Feb 5, 2025
1 parent c68eb6f commit 51c4e74
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion completion/bash/tlp.bash_completion
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ _batteries() {
fi
}

_target_level() {
local threshf

threshf="/sys/class/power_supply/${COMP_WORDS[2]}/charge_control_end_threshold"
if [ -f "$threshf" ]; then
COMPREPLY=( $(compgen -W "$(cat "$threshf")" -- ${cur}) )
fi
}

_tlp() {
local cur prev words cword opts bats
_init_completion || return
Expand Down Expand Up @@ -49,7 +58,7 @@ _tlp() {

3)
if [ "${COMP_WORDS[1]}" = "discharge" ]; then
COMPREPLY=( $(compgen -W "0" -- ${cur}) )
_target_level
return 0
fi
;;
Expand Down

0 comments on commit 51c4e74

Please sign in to comment.