Skip to content

[feature]stay awake #631

Closed
Closed

Description

@Ejsstiil

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.

Activity

  1. srevinsaju commented on Jul 1, 2019

    @srevinsaju

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

  2. rom1v commented on Jul 1, 2019

    @rom1v
    Collaborator

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

  3. rom1v commented on Jul 1, 2019

    @rom1v
    Collaborator
  4. Ejsstiil commented on Jul 2, 2019

    @Ejsstiil
    Author

    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".

  5. cagnulein commented on Jul 15, 2019

    @cagnulein
  6. yamsu commented on Jul 19, 2019

    @yamsu

    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.

  7. madduck commented on Jan 7, 2020

    @madduck
    Contributor

    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?

  8. amosbird commented on Feb 25, 2020

    @amosbird

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

  9. yamsu commented on Apr 1, 2020

    @yamsu

    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.

  10. added a commit that references this issue on May 2, 2020
    c770243
  11. rom1v commented on May 2, 2020

    @rom1v
    Collaborator

    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).

  12. edmundlaugasson commented on Aug 9, 2021

    @edmundlaugasson

    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?

  13. roirraWedorehT commented on May 6, 2022

    @roirraWedorehT

    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.

  14. rom1v commented on May 6, 2022

    @rom1v
    Collaborator

    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).

  15. Kareem-Zaid commented on Jul 6, 2024

    @Kareem-Zaid
    scrcpy --turn-screen-off
    scrcpy -S   # short version
    

    #https://github.com/Genymobile/scrcpy/blob/master/doc/device.md#turn-screen-off

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions