Skip to content

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

Open

Description

@oscarb

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

Activity

  1. rom1v commented on Mar 22, 2022

    @rom1v
    Collaborator

    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.

  2. rom1v commented on Mar 22, 2022

    @rom1v
    Collaborator

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

  3. rom1v commented on Mar 22, 2022

    @rom1v
    Collaborator

    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.

  4. oscarb commented on Mar 22, 2022

    @oscarb
    Author

    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 😅

  5. 0x2539 commented on Jun 13, 2022

    @0x2539

    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.

  6. added a commit that references this issue on Aug 3, 2022
  7. Architector4 commented on Feb 11, 2025

    @Architector4

    Ran into this and figured out that you can use the -s number parameter to connect to a specific device via its serial number. With the error that pops up in this scenario, scrcpy shows a list of devices like in the post above, with the second column consisting of serial numbers. You can then run scrcpy -s QZ125F6WA1 to connect to the first device, or scrcpy -s emulator-5554 to the second.

    This allows picking which device to connect to in a protocol-agnostic way, as far as i can tell, which means this issue has a solution. But I feel like the error message could be a little better.

    The line Select a device via -s (--serial), -d (--select-usb) or -e (--select-tcpip) lead me to believe that in these 3 options, two of which are about connection method, --serial is the option for connecting via a serial port and has nothing to do with devices's serial numbers. Reading the man page helped, but it could be a little clearer that this is what that does I think.

  8. added a commit that references this issue on Sep 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions