termux-app
termux-app copied to clipboard
[Feature]: incremental wakelock
Feature description
I use the wakelock mainly to avoid problems when accessing termux via ssh, but having it permanently seems to roughly double power consumption while the phone is not used.
So I bastled a thing to have a wakelock put in place when the first session is started, and released when there are no more sessions :
in .profile
:
fich="$HOME/.termux/nbSessions"
if [[ -f "$fich" ]]; then
nbSessions="$(cat $fich)"
else
nbSessions=0
fi
if (( $nbSessions == 0 )); then
termux-wake-lock
fi
((nbSessions++))
echo $nbSessions > $fich
in .bash_logout
fich="$HOME/.termux/nbSessions"
if [[ -f "$fich" ]]; then
nbSessions="$(cat $fich)"
else
nbSessions=1
fi
((nbSessions--))
if (( $nbSessions == 0 )); then
termux-wake-unlock
fi
echo $nbSessions > $fich
But this is rather crude, and furthermore, there are probably more general use case when a user wants a wakelock for certain reasons but not others, and those reasons can chronologically overlap.
So I suggest an "incremental" variant for termux-wake-lock
and termux-wake-unlock
with an internal number of "currently active locks" that get incremented or decremented, and the actual locking/unlocking mechanism performed when reaching zero. The notification could also mention the number of active locks.
Additional information
I do not know what to say here.
So you requesting this just to avoid coding desired behavior when to enable/disable wake lock?
Sorry, I do no understand your sentence.
Cordialement,
Yann Salmon
Depuis mon téléphone ; excusez la brièveté.