Scrcpy: set display brightness

Created on 29 Mar 2018  Â·  6Comments  Â·  Source: Genymobile/scrcpy

It would be great if scrcpy could set device brightness to 0 on start and reset it on exit.
The current value can be accessed using adb shell settings get system screen_brightness, and can be set using adb shell settings put system screen_brightness XX where XX ranges from 0 to 255.

On a side note, maybe a user can be allowed to run scripts at the start and exit of scrcpy.

custom actions

Most helpful comment

I don't know if brightness deserve its own option too

Yeah you're right. A wrapper script is more than enough.
Script samples for the most frequent actions can be added to the readme though.

For example, this is the function I'm using -

function scrcpy () {
    brightness=$(adb shell settings get system screen_brightness)
    adb shell settings put system screen_brightness_mode 0
    adb shell settings put system screen_brightness 0
    adb shell svc power stayon usb
    command scrcpy
    adb shell settings put system screen_brightness_mode 1
    adb shell settings put system screen_brightness $brightness
    adb shell svc power stayon false
}

All 6 comments

All of this can be achieved using a bash script.
Closing.

The current value can be accessed using adb shell settings get system screen_brightness, and can be set using adb shell settings put system screen_brightness XX where XX ranges from 0 to 255.

For completeness, screen_brightness_mode must also be set to 0:

adb shell settings put system screen_brightness_mode 0
adb shell settings put system screen_brightness 0

On a side note, maybe a user can be allowed to run scripts at the start and exit of scrcpy.

See https://github.com/Genymobile/scrcpy/issues/96.

All of this can be achieved using a bash script.

:wink:

I still implemented _show touches_ as an option. I don't know if brightness deserve its own option too… For now, I don't think so.

I don't know if brightness deserve its own option too

Yeah you're right. A wrapper script is more than enough.
Script samples for the most frequent actions can be added to the readme though.

For example, this is the function I'm using -

function scrcpy () {
    brightness=$(adb shell settings get system screen_brightness)
    adb shell settings put system screen_brightness_mode 0
    adb shell settings put system screen_brightness 0
    adb shell svc power stayon usb
    command scrcpy
    adb shell settings put system screen_brightness_mode 1
    adb shell settings put system screen_brightness $brightness
    adb shell svc power stayon false
}

:+1:

One question: I never used the command built-in bash command. What's the benefit concretely.

As a suggestion, you could forward the arguments to _scrcpy_:

    command scrcpy "$@"

The command function is there only because I wanted the function to have the same name.
If this function is called without command, it will keep calling itself recursively.

Totally forgot about passing the arguments. Thank you!

A shortcut to turn device screen off is implemented on dev by 12a3bb25d39037931f577dc0165b3e517aad92df.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sennight picture sennight  Â·  3Comments

fleytman picture fleytman  Â·  4Comments

tonyyang924 picture tonyyang924  Â·  4Comments

npes87184 picture npes87184  Â·  3Comments

fernandofreamunde picture fernandofreamunde  Â·  4Comments