mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-09-01 15:15:44 +00:00
Add --no-cleanup option
It might be useful not to cleanup on exit, for example to leave the screen turned off, or keep the server binary on the device (via the server option "cleanup=false"). Fixes #1764 <https://github.com/Genymobile/scrcpy/issues/1764> PR #3020 <https://github.com/Genymobile/scrcpy/pull/3020>
This commit is contained in:
parent
bb991f829c
commit
ccbe370cc5
9 changed files with 46 additions and 5 deletions
|
@ -146,6 +146,12 @@ It may only work over USB, and is currently only supported on Linux.
|
|||
|
||||
Also see \fB\-\-hid\-keyboard\fR.
|
||||
|
||||
.TP
|
||||
.B \-\-no\-cleanup
|
||||
By default, scrcpy removes the server binary from the device and restores the device state (show touches, stay awake and power mode) on exit.
|
||||
|
||||
This option disables this cleanup.
|
||||
|
||||
.TP
|
||||
.B \-\-no\-clipboard\-autosync
|
||||
By default, scrcpy automatically synchronizes the computer clipboard to the device clipboard before injecting Ctrl+v, and the device clipboard to the computer clipboard whenever it changes.
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
#define OPT_RAW_KEY_EVENTS 1034
|
||||
#define OPT_NO_DOWNSIZE_ON_ERROR 1035
|
||||
#define OPT_OTG 1036
|
||||
#define OPT_NO_CLEANUP 1037
|
||||
|
||||
struct sc_option {
|
||||
char shortopt;
|
||||
|
@ -250,6 +251,14 @@ static const struct sc_option options[] = {
|
|||
"is preserved.\n"
|
||||
"Default is 0 (unlimited).",
|
||||
},
|
||||
{
|
||||
.longopt_id = OPT_NO_CLEANUP,
|
||||
.longopt = "no-cleanup",
|
||||
.text = "By default, scrcpy removes the server binary from the device "
|
||||
"and restores the device state (show touches, stay awake and "
|
||||
"power mode) on exit.\n"
|
||||
"This option disables this cleanup."
|
||||
},
|
||||
{
|
||||
.longopt_id = OPT_NO_CLIPBOARD_AUTOSYNC,
|
||||
.longopt = "no-clipboard-autosync",
|
||||
|
@ -1535,6 +1544,9 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[],
|
|||
case OPT_NO_DOWNSIZE_ON_ERROR:
|
||||
opts->downsize_on_error = false;
|
||||
break;
|
||||
case OPT_NO_CLEANUP:
|
||||
opts->cleanup = false;
|
||||
break;
|
||||
case OPT_OTG:
|
||||
#ifdef HAVE_USB
|
||||
opts->otg = true;
|
||||
|
|
|
@ -62,4 +62,5 @@ const struct scrcpy_options scrcpy_options_default = {
|
|||
.tcpip_dst = NULL,
|
||||
.select_tcpip = false,
|
||||
.select_usb = false,
|
||||
.cleanup = true,
|
||||
};
|
||||
|
|
|
@ -137,6 +137,7 @@ struct scrcpy_options {
|
|||
const char *tcpip_dst;
|
||||
bool select_usb;
|
||||
bool select_tcpip;
|
||||
bool cleanup;
|
||||
};
|
||||
|
||||
extern const struct scrcpy_options scrcpy_options_default;
|
||||
|
|
|
@ -320,6 +320,7 @@ scrcpy(struct scrcpy_options *options) {
|
|||
.downsize_on_error = options->downsize_on_error,
|
||||
.tcpip = options->tcpip,
|
||||
.tcpip_dst = options->tcpip_dst,
|
||||
.cleanup = options->cleanup,
|
||||
};
|
||||
|
||||
static const struct sc_server_callbacks cbs = {
|
||||
|
|
|
@ -244,6 +244,10 @@ execute_server(struct sc_server *server,
|
|||
// By default, downsize_on_error is true
|
||||
ADD_PARAM("downsize_on_error=false");
|
||||
}
|
||||
if (!params->cleanup) {
|
||||
// By default, cleanup is true
|
||||
ADD_PARAM("cleanup=false");
|
||||
}
|
||||
|
||||
#undef ADD_PARAM
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ struct sc_server_params {
|
|||
const char *tcpip_dst;
|
||||
bool select_usb;
|
||||
bool select_tcpip;
|
||||
bool cleanup;
|
||||
};
|
||||
|
||||
struct sc_server {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue