Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: incremental wakelock #3694

Open
ysalmon opened this issue Nov 10, 2023 · 2 comments
Open

[Feature]: incremental wakelock #3694

ysalmon opened this issue Nov 10, 2023 · 2 comments

Comments

@ysalmon
Copy link

ysalmon commented Nov 10, 2023

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.

@sylirre
Copy link
Member

sylirre commented Nov 11, 2023

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

@ysalmon
Copy link
Author

ysalmon commented Nov 23, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants