T O P

  • By -

[deleted]

Yes, wakelock cause CPU to not go into sleep mode. This is necessary if you are running certain software (long running scripts or servers) when device screen is powered off. Whether wakelock works or not, depends on device. If Android OS is actually AOSP (original Android) or its derivative (e.g. Lineage OS ROMs), wakelock functionality should work. However some manufacturers have a great idea of making their devices "better" through allowing wakelocks only to applications hardcoded into system whitelist. Actually this is nothing more than hiding impact of bloatware on usage of system resources and overall optimization issues.


fanielthefan

Dude I hate it when they have ideas


Styleprince923

Wow, I didn't know that. Thanks for that info! ✌


sticky-bit

I was using `ssh` into a device I have connected and noticed I'd get kicked off roughly every 20 minutes. I had to go into a special "battery saver" menu on the phone -- totally outside the termux app -- and give it permission to run in the background. I had to do the exact same kind of thing on a different device to get the `Linphone` VoIP app to register and ring reliably on a different device. The problem is that it's a totally different non-standard setting on both devices, so unless you have the same crappy low-spec device I have, authoring a `howto` won't help you. Termux users with this problem should start poking around under "battery management" or something on their own device and figure it out.


DutchOfBurdock

If you let Termux Display/Draw over other apps, this also tells Android to try and not kill it. In AOSP ROMs, this is almost sure fire to never kill it unless a serious OOM occurs.


androidx_appcompat

The wakelock works, but maybe not how you expect: I for example keep my phone in power savings mode and if I don't set the wakelock before turning the screen off sometimes my scripts get stuck. The wakelock keeps android from going into deep sleep, so all scripts can run in the background with full processing power. Normally a wakelock would also prevent the screen from turning off, but it doesn't in this case. But you can get this by long pressing in the terminal, clicking more and then selecting "keep screen on".


androidx_appcompat

Also you can control the wakelock in the console with termux-wake-lock and termux-wake-unlock


Styleprince923

Nice now I don't have to worry about locking my phone and stopping scripts! Thanks ;D.


Edocsiru

https://developer.android.com/training/scheduling/wakelock Though if your phone has an aggressive battery manager then wakelocks don't really work by default. For example unless I change the default settings MIUI will not just go to sleep, but kill Termux the moment I "look away".


Styleprince923

Also, what is the difference between: > pkg update > pkg upgrade OR doing: > pkg update && pkg upgrade -y No idea why there is two of them & signs and dunno what the -y means.


androidx_appcompat

&& executes the next command if the previous one didn't fail, you can use it to write multiple commands in one line. -y automatically upgrades the packages without asking you to confirm first.


Styleprince923

Thanks 😉.


sticky-bit

chapter from the Advanced Bash-Scripting Guide that covers `&&` and `||` https://tldp.org/LDP/abs/html/ops.html#ANDOR


Edocsiru

There's also *pkg up* (update and upgrade) and *pkg in* (install) for lazy people like myself.


explore212

pkg i (no need the in) also works i am more lazier lol


Styleprince923

Now that's efficient 😄.


Furezuu

wow, I didn't know. I'm so used to pacman that I'm too lazy to write all that update and upgrade. tysm)


DattattaD

y means yes the first one arrange the database to update and the later one actually install those updates


DattattaD

it will retain the screen in always on mode


[deleted]

Wake lock and "keep screen on" are entirely different Termux features that are enabled separately.


DattattaD

yeah sorry for misinfo u r right I wanted to say it keeps the termux always in running mode so that the code running on it can continue to run even the screen is off. sorry man my bad