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

Option to power-off at start #3148

Closed
1 task done
madduck opened this issue Mar 25, 2022 · 9 comments
Closed
1 task done

Option to power-off at start #3148

madduck opened this issue Mar 25, 2022 · 9 comments

Comments

@madduck
Copy link
Contributor

madduck commented Mar 25, 2022

I have a device permanently living next to my computer, and I use the systemd integration from #3101, so basically I always have scrcpy running. Unless I power-off (Alt-P), scrcpy will occupy the CPU all time (#3112). I am looking for an option that automatically hits the power button after connection, similarly to how --turn-screen-off just turns the device screen off. This would allow auto-connection, but without involving the CPU too much until I need to interact.

Thanks!

@rom1v
Copy link
Collaborator

rom1v commented Mar 25, 2022

In fact, unless --no-control is enabled, the server explicitly power the device screen on on start. An option --no-power-on could be added.

Do you want to work on it?

@madduck
Copy link
Contributor Author

madduck commented Apr 3, 2022

@rom1v this does indeed look like it should be easy to do, but those are famous last words… I haven't done Java in more than 2 decades, and I've never actually developed for Android, I wouldn't even know how to test this… or are there any easy resources I can peruse to get me started?

@rom1v
Copy link
Collaborator

rom1v commented Apr 7, 2022

You need to add a command line option, and propagate it to the server. It's very similar to ccbe370 which adds the --no-cleanup option.

In addition, you should also add the option in bash-completion and zsh-completion scripts, which were written after --no-cleanup.

rom1v added a commit that referenced this issue Apr 23, 2022
By default, on start, the device is powered on. To prevent this
behavior, add a new option --no-power-on.

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

rom1v commented Apr 23, 2022

I implemented it: #3210. Please review/test.

rom1v added a commit that referenced this issue Apr 23, 2022
By default, on start, the device is powered on. To prevent this
behavior, add a new option --no-power-on.

Fixes #3148 <#3148>
PR #3210 <#3210>
rom1v added a commit that referenced this issue Apr 23, 2022
By default, on start, the device is powered on. To prevent this
behavior, add a new option --no-power-on.

Fixes #3148 <#3148>
PR #3210 <#3210>
@rom1v rom1v closed this as completed in 0fca2ad Apr 28, 2022
@madduck
Copy link
Contributor Author

madduck commented Apr 29, 2022

@rom1v Sorry I have not responded earlier. I'm in the process of moving to another country, so there's lot in the air.

I've just tested this, and it seems to work beautifully. Thank you!

@madduck
Copy link
Contributor Author

madduck commented May 24, 2022

FYI, it does not work with a Google Pixel 3 with stock ROM. power_on=false is correctly sent to the server, but the display does power on…

@rom1v
Copy link
Collaborator

rom1v commented May 24, 2022

@madduck So with scrcpy v1.24, if you execute scrcpy --no-power-on (while the display is off), the display is powered on?

@madduck
Copy link
Contributor Author

madduck commented May 24, 2022

No, if the display is off, then it works. I see where the problem is:

  1. Plug in USB;
  2. Screen powers on;
  3. udev fires scrcpy rule;
  4. scrcpy starts, while display is on.

The Samsung Galaxy S7 and the OnePlus 5T do not turn the display on when USB is connected, so that is the difference. Sorry for the noise.

@madduck
Copy link
Contributor Author

madduck commented May 24, 2022

I had the "Stay Awake" developer option on. Oops.

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