mirror of
https://github.com/Genymobile/scrcpy.git
synced 2024-09-19 05:31:21 +02:00
dd36d6135f
In addition to --camera-size to specify an explicit size, make it possible to select the camera size automatically, respecting the maximum size (already used for display mirroring) and an aspect ratio. For example, "scrcpy --video-source=camera" followed by: - (no additional arguments) : mirrors at the maximum size, any a-r - -m1920 : only consider valid sizes having both dimensions not above 1920 - --camera-ar=4:3 : only consider valid sizes having an aspect ratio of 4:3 (+/- 10%) - -m2048 --camera-ar=1.6 : only consider valid sizes having both dimensions not above 2048 and an aspect ratio of 1.6 (+/- 10%) PR #4213 <https://github.com/Genymobile/scrcpy/pull/4213> Co-authored-by: Simon Chan <1330321+yume-chan@users.noreply.github.com>
185 lines
4.8 KiB
Text
185 lines
4.8 KiB
Text
_scrcpy() {
|
|
local cur prev words cword
|
|
local opts="
|
|
--always-on-top
|
|
--audio-bit-rate=
|
|
--audio-buffer=
|
|
--audio-codec=
|
|
--audio-codec-options=
|
|
--audio-encoder=
|
|
--audio-source=
|
|
--audio-output-buffer=
|
|
-b --video-bit-rate=
|
|
--camera-ar=
|
|
--camera-id=
|
|
--camera-facing=
|
|
--camera-size=
|
|
--crop=
|
|
-d --select-usb
|
|
--disable-screensaver
|
|
--display-id=
|
|
--display-buffer=
|
|
-e --select-tcpip
|
|
-f --fullscreen
|
|
--force-adb-forward
|
|
--forward-all-clicks
|
|
-h --help
|
|
--kill-adb-on-close
|
|
-K --hid-keyboard
|
|
--legacy-paste
|
|
--list-camera-sizes
|
|
--list-cameras
|
|
--list-displays
|
|
--list-encoders
|
|
--lock-video-orientation
|
|
--lock-video-orientation=
|
|
-m --max-size=
|
|
-M --hid-mouse
|
|
--max-fps=
|
|
-n --no-control
|
|
-N --no-playback
|
|
--no-audio
|
|
--no-audio-playback
|
|
--no-cleanup
|
|
--no-clipboard-autosync
|
|
--no-downsize-on-error
|
|
--no-key-repeat
|
|
--no-mipmaps
|
|
--no-power-on
|
|
--no-video
|
|
--no-video-playback
|
|
--otg
|
|
-p --port=
|
|
--pause-on-exit
|
|
--pause-on-exit=
|
|
--power-off-on-close
|
|
--prefer-text
|
|
--print-fps
|
|
--push-target=
|
|
-r --record=
|
|
--raw-key-events
|
|
--record-format=
|
|
--render-driver=
|
|
--require-audio
|
|
--rotation=
|
|
-s --serial=
|
|
-S --turn-screen-off
|
|
--shortcut-mod=
|
|
-t --show-touches
|
|
--tcpip
|
|
--tcpip=
|
|
--time-limit=
|
|
--tunnel-host=
|
|
--tunnel-port=
|
|
--v4l2-buffer=
|
|
--v4l2-sink=
|
|
-v --version
|
|
-V --verbosity=
|
|
--video-codec=
|
|
--video-codec-options=
|
|
--video-encoder=
|
|
--video-source=
|
|
-w --stay-awake
|
|
--window-borderless
|
|
--window-title=
|
|
--window-x=
|
|
--window-y=
|
|
--window-width=
|
|
--window-height="
|
|
|
|
_init_completion -s || return
|
|
|
|
case "$prev" in
|
|
--video-codec)
|
|
COMPREPLY=($(compgen -W 'h264 h265 av1' -- "$cur"))
|
|
return
|
|
;;
|
|
--audio-codec)
|
|
COMPREPLY=($(compgen -W 'opus aac raw' -- "$cur"))
|
|
return
|
|
;;
|
|
--video-source)
|
|
COMPREPLY=($(compgen -W 'display camera' -- "$cur"))
|
|
return
|
|
;;
|
|
--audio-source)
|
|
COMPREPLY=($(compgen -W 'output mic' -- "$cur"))
|
|
return
|
|
;;
|
|
--camera-facing)
|
|
COMPREPLY=($(compgen -W 'front back external' -- "$cur"))
|
|
return
|
|
;;
|
|
--lock-video-orientation)
|
|
COMPREPLY=($(compgen -W 'unlocked initial 0 1 2 3' -- "$cur"))
|
|
return
|
|
;;
|
|
--pause-on-exit)
|
|
COMPREPLY=($(compgen -W 'true false if-error' -- "$cur"))
|
|
return
|
|
;;
|
|
-r|--record)
|
|
COMPREPLY=($(compgen -f -- "$cur"))
|
|
return
|
|
;;
|
|
--record-format)
|
|
COMPREPLY=($(compgen -W 'mkv mp4' -- "$cur"))
|
|
return
|
|
;;
|
|
--render-driver)
|
|
COMPREPLY=($(compgen -W 'direct3d opengl opengles2 opengles metal software' -- "$cur"))
|
|
return
|
|
;;
|
|
--rotation)
|
|
COMPREPLY=($(compgen -W '0 1 2 3' -- "$cur"))
|
|
return
|
|
;;
|
|
--shortcut-mod)
|
|
# Only auto-complete a single key
|
|
COMPREPLY=($(compgen -W 'lctrl rctrl lalt ralt lsuper rsuper' -- "$cur"))
|
|
return
|
|
;;
|
|
-V|--verbosity)
|
|
COMPREPLY=($(compgen -W 'verbose debug info warn error' -- "$cur"))
|
|
return
|
|
;;
|
|
-s|--serial)
|
|
# Use 'adb devices' to list serial numbers
|
|
COMPREPLY=($(compgen -W "$("${ADB:-adb}" devices | awk '$2 == "device" {print $1}')" -- ${cur}))
|
|
return
|
|
;;
|
|
--audio-bit-rate \
|
|
|--audio-buffer \
|
|
|-b|--video-bit-rate \
|
|
|--audio-codec-options \
|
|
|--audio-encoder \
|
|
|--audio-output-buffer \
|
|
|--camera-ar \
|
|
|--camera-id \
|
|
|--camera-size \
|
|
|--crop \
|
|
|--display-id \
|
|
|--display-buffer \
|
|
|--max-fps \
|
|
|-m|--max-size \
|
|
|-p|--port \
|
|
|--push-target \
|
|
|--rotation \
|
|
|--tunnel-host \
|
|
|--tunnel-port \
|
|
|--v4l2-buffer \
|
|
|--v4l2-sink \
|
|
|--video-codec-options \
|
|
|--video-encoder \
|
|
|--tcpip \
|
|
|--window-*)
|
|
# Option accepting an argument, but nothing to auto-complete
|
|
return
|
|
;;
|
|
esac
|
|
|
|
COMPREPLY=($(compgen -W "$opts" -- "$cur"))
|
|
[[ $COMPREPLY == *= ]] && compopt -o nospace
|
|
}
|
|
|
|
complete -F _scrcpy scrcpy
|