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

When multiple devices are present, let the user pick one. #3137

Open
1 task done
oscarb opened this issue Mar 22, 2022 · 5 comments
Open
1 task done

When multiple devices are present, let the user pick one. #3137

oscarb opened this issue Mar 22, 2022 · 5 comments

Comments

@oscarb
Copy link

oscarb commented Mar 22, 2022

Is your feature request related to a problem? Please describe.
I'm always frustrated when I run scrcpy only to realize I had multiple devices/emulators connected and then need to copy the serial of one to connect to the device of my choice.

Describe the solution you'd like
Instead of yielding an error, output the list of devices with each device prefixed by a number and then have scrcpy await user input for which device to use:

> scrcpy 
Multiple (3) ADB devices:
1) (usb)  QZ125F6WA1                      device  XQ_BQ52
2) (usb)  emulator-5554                   device  sdk_google_atv_x86
3) (usb)  emulator-5555                   device  sdk_google_atv_x86
Which device would you like to use (0 to exit)? 2

The copy could perhaps be a bit better.

Describe alternatives you've considered
An alternate solution would perhaps be if I wrote my own script which wraps the scrcpy tool with logic based on the scrcpy output, but that could likely break at any time.

Additional context
N/A

@rom1v
Copy link
Collaborator

rom1v commented Mar 22, 2022

Instead of yielding an error, output the list of devices with each device prefixed by a number and then have scrcpy` await user input for which device to use:

I already considered that, but scrcpy could not rely on user input, the user may start it without a console (that's quite common). And even when a console is available, it may be started from a script which does not expect it to wait.

@rom1v
Copy link
Collaborator

rom1v commented Mar 22, 2022

#3005 added -d and -e to select USB and TCP/IP devices. But contrary to adb, an emulator is considered as an USB device. This is a bug, I'll fix it in the next release.

In your specific case, that would allow to call scrcpy -d to select the real device.

rom1v added a commit that referenced this issue Mar 22, 2022
Emulators were wrongly considered as USB devices, so they were selected
using -d instead of -e (which was inconsistent with the adb behavior).

Refs #3005 <#3005>
Refs #3137 <#3137>
rom1v added a commit that referenced this issue Mar 22, 2022
Emulators were wrongly considered as USB devices, so they were selected
using -d instead of -e (which was inconsistent with the adb behavior).

Refs #3005 <#3005>
Refs #3137 <#3137>
@rom1v
Copy link
Collaborator

rom1v commented Mar 22, 2022

But contrary to adb, an emulator is considered as an USB device. This is a bug, I'll fix it in the next release.

Fixed by #3140.

@oscarb
Copy link
Author

oscarb commented Mar 22, 2022

Instead of yielding an error, output the list of devices with each device prefixed by a number and then have scrcpy await user input for which device to use:

I already considered that, but scrcpy could not rely on user input, the user may start it without a console (that's quite common). And even when a console is available, it may be started from a script which does not expect it to wait.

Thanks for taking the time to reply, and that you already had given it some thought :) Now that I understand better the reasons for not implementing a feature like this, feel free to close this.

I'm happy I discovered something else totally unintentionally 😅

@0x2539
Copy link

0x2539 commented Jun 13, 2022

Instead of yielding an error, output the list of devices with each device prefixed by a number and then have scrcpy` await user input for which device to use:

I already considered that, but scrcpy could not rely on user input, the user may start it without a console (that's quite common). And even when a console is available, it may be started from a script which does not expect it to wait.

What I've seen other libraries do in this case is that you pass an argument to the command, such as -i which would make it "interactable". So if you don't pass -i nothing is changed, it will throw an error just like before, but if you pass -i it will wait for user input if necessary.

MrLeopard added a commit to MrLeopard/scrcpy that referenced this issue Aug 3, 2022
easy to use when multiple devices connected, see Genymobile#3137
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

3 participants