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]stay awake #631

Closed
Ejsstiil opened this issue Jul 1, 2019 · 13 comments
Closed

[feature]stay awake #631

Ejsstiil opened this issue Jul 1, 2019 · 13 comments

Comments

@Ejsstiil
Copy link

Ejsstiil commented Jul 1, 2019

Really great application!! Small, fast, simple, functional!
Suggestion:
Would be possible to send some silent actions to the controlled mobile to assure the phone never get locked? Like "clicking" somewhere or send any non-action character to the phone.
Create a new keyboard shortcut to toggle it on/off, and commandline option for activate it on startup.
Why:
Using "Stay awake" from Developer options is not viable, because that keeps phone lit even when its on charger as well (during night for ex.)
Phone (on its default user preferences) gets locked after 1min. or so and you have to manually unlock it every time.
Along with -S option, phone's physical screen will not wear off.

@srevinsaju
Copy link

Are you having 'caffeine' QS notification tile. I use that to keep the screen on with scrcpy?

@rom1v
Copy link
Collaborator

rom1v commented Jul 1, 2019

A good solution would be to acquire a wake lock, but it does not work: #175 (comment)

@rom1v
Copy link
Collaborator

rom1v commented Jul 1, 2019

Ref: PowerManager.wakeUp()

@Ejsstiil
Copy link
Author

Ejsstiil commented Jul 2, 2019

Are you having 'caffeine' QS notification tile. I use that to keep the screen on with scrcpy?

Wow, thats awesome! It works great! It still require's an extra user action to turn it on after scrcpy connects though, but it solves "the need".

@cagnulein
Copy link

@yamsu
Copy link

yamsu commented Jul 19, 2019

The "stay awake" option is available on most phones, through the System>developer tab. This keeps the phone from sleeping and locking. However, it is not a good option to keep active especially with AMOLED displays. A static screen image will burn in on the display. Checkout this link for details, stackoverflow
What would be ideal is if the Stay Awake option is toggled on only during a scrcpy session.
I use a bash script to achieve the above. Only issue is that the mobile phones should not be unplugged without disconnecting through the script.

Bash Script follows:

#!/usr/bin/env bash
scrcpy -S &
sleep 2
adb shell 'svc power stayon usb'
decision="n"
while [ "$decision" != "y" ]
do
echo "Disconnect? (y/n)"
read -n 1 decision

if  [ "$decision" == "y" ]; then
	adb shell 'svc power stayon false'
	echo "Disconnected on `date`"
	exit 0
fi
done

Command to activate "Stay Awake" adb shell svc power stayon usb
Command to deactivate "Stay Awake" adb shell svc power stayon false

In order to support multiple phones add -s <SerialNo> to the scrcpy and adb commands. Note there needs to be a small delay between multiple scrcpy calls.

@madduck
Copy link
Contributor

madduck commented Jan 7, 2020

The problem with "stay awake" is that if the phone gets disconnected (because I pick it up for a call without thinking), then the option does not get turned off.

Would it be possible to schedule an event to run every couple of minutes, which turns off the stay-awake if scrcpy turned it on, and turn it on again, if scrcpy is still connected?

@amosbird
Copy link

stay awake is not perfect. I'd still like to turn off the screen but without locking it. Is it even possible?

@yamsu
Copy link

yamsu commented Apr 1, 2020

The problem with "stay awake" is that if the phone gets disconnected (because I pick it up for a call without thinking), then the option does not get turned off.

Would it be possible to schedule an event to run every couple of minutes, which turns off the stay-awake if scrcpy turned it on, and turn it on again, if scrcpy is still connected?

Yeah this happens to be a lot especially after writing the bash script to use stay awake. Thankfully after a bit of muscle memory i invariably disconnect through the script. Its not great but it works and protects the display.

rom1v added a commit that referenced this issue May 2, 2020
Add an option to prevent the device to sleep:

    scrcpy --stay-awake
    scrcpy -w

The initial state is restored on exit.

Fixes #631 <#631>
@rom1v
Copy link
Collaborator

rom1v commented May 2, 2020

I just implemented it on dev branch:

scrcpy --stay-awake
scrcpy -w

c770243

The initial state is restored, even on device disconnection (I implemented 2f74ec2 just before).

@edmundlaugasson
Copy link

edmundlaugasson commented Aug 9, 2021

Things are getting more interesting, when multiple devices are connected. Then even adb shell svc power stayon true does not work. Any idea, how to get awake state for multiple devices, while using Ubuntu 20.04 LTS and its based distros, where scrcpy v1.12 is available?

@roirraWedorehT
Copy link

roirraWedorehT commented May 6, 2022

Edit: Thanks @rom1v for the clarification. I missed that if that information was presented in the details of the option, but my excuse is I was reading a ton about all the different options that are available. Cheers!

For what it's worth, on my Samsung Galaxy Tab S8 Ultra Wi-Fi model (SM-X900), scrcpy's still allowing the device to lock, at least with both the -S and -w options. This app "Caffeine - Keep Screen On" https://play.google.com/store/apps/details?id=moe.zhs.caffeine&hl=en_US&gl=US (I haven't tried the other similar one linked earlier) is working fine to still respect scrcpy's ability to keep the physical screen off while keeping the device unlocked and showing full-time in the remote session. I had to enable the "Caffeine - Keep Screen On" app's Compatibility Mode because the default mode didn't work, and you have to manually turn it on and off via Quick Setting tiles.

You can at least configure it to automatically turn off if you manually power the screen on or off. When used with scrcpy's --power-off-on-close option, that does count as an actual screen power event and turns "Caffeine - Keep Screen On" app off in conjunction with the app's option.

I also haven't looked into using Tasker (I am rooted) to automatically turn Caffeine on when / if it can detect when I'm remoted in using scrcpy.

@rom1v
Copy link
Collaborator

rom1v commented May 6, 2022

scrcpy's still allowing the device to lock

The option is only effective over USB (that's a limitation of the Android settings stay_awake_while_plugged_in).

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

No branches or pull requests

9 participants