termux-app icon indicating copy to clipboard operation
termux-app copied to clipboard

[Feature]: incremental wakelock

Open ysalmon opened this issue 1 year ago • 2 comments

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.

ysalmon avatar Nov 10 '23 21:11 ysalmon

So you requesting this just to avoid coding desired behavior when to enable/disable wake lock?

sylirre avatar Nov 11 '23 06:11 sylirre

Sorry, I do no understand your sentence.

Cordialement,

Yann Salmon

Depuis mon téléphone ; excusez la brièveté.

ysalmon avatar Nov 23 '23 21:11 ysalmon