Synergy-core 如何用 deskflow-client 命令行参数连接服务器并设置 --invert-scroll 滚动方向
2026/9/15 11:59:47 网站建设 项目流程

Synergy-core 如何用 deskflow-client 命令行参数连接服务器并设置 --invert-scroll 滚动方向

【免费下载链接】synergy-coreShare a single keyboard and mouse between multiple computers.项目地址: https://gitcode.com/GitHub_Trending/sy/synergy-core

Synergy-core(Deskflow 上游代码库)中除了图形界面入口deskflow之外,还有一个独立的客户端二进制deskflow-client,可以在不经过 GUI 的情况下,用命令行参数指定服务器地址、以独立客户端身份加入鼠标键盘共享网络。本文的任务是:用deskflow-client的连接参数连上已运行的服务器,并在客户端本机反转滚轮方向(--invert-scroll)。适用前提:服务器上已有一台机器运行着 Deskflow 服务端;客户端机器上已有所需平台的deskflow-client可执行文件(预构建版本或自行编译产物)。

准备:拿到 deskflow-client 二进制

deskflow-client的目标名由构建配置固定为deskflow-client(见 Definitions.cmake),入口源码在 deskflow-client.cpp,内部通过 ClientApp 完成参数解析与启动。

如果手上没有预构建版本,可以按 BUILD.md 从源码编译。该流程会安装构建依赖并执行 CMake 配置与编译,属于本地构建操作,只影响当前机器的构建环境:

# Linux / macOS / BSD 系安装依赖(Windows 用 python scripts/install_deps.py) ./scripts/install_deps.sh # 配置 cmake -B build # 编译 cmake --build build -j8

编译完成后运行测试(可选):./build/bin/unittests./build/bin/integtests;BUILD.md 给出的运行入口是./build/bin/deskflow(GUI),客户端二进制位于同一build/bin目录,Linux 下会安装到bin(见 CMakeLists.txt)。

客户端连接参数一览

以下描述均取自 ClientApp.cpp 中--help输出的用法说明,解析逻辑在 ArgParser.cpp:

参数文档中的说明
<server-address>必选的位置参数,服务器地址,形式为[<hostname>][:<port>];端口缺省时使用默认端口24800(定义于 protocol_types.h)
--invert-scrollinvert scroll direction on this computer(在本机反转滚动方向)
--yscroll <delta>defines the vertical scrolling delta, which is 120 by default(定义垂直滚动增量,默认 120)
--address <address>/-alocal network interface address(本机使用的网络接口地址)
--sync-languageenable language synchronization(启用语言同步)
--hostact as a host; invert server/client mode and listen instead of connecting(反转服务端/客户端模式,改为监听而非主动连接)
-n, --name <name>屏幕名。默认取本机主机名(见 ArgParser.cpp),需要与服务器配置文件中section: screens里声明的屏幕名对应,服务器配置格式可参考 deskflow.conf.example
-d, --debug <level>/-l, --log <file>调整日志级别 / 指定日志文件
-f, --no-daemon不以后台守护进程方式运行(默认会 daemon 化)
-h, --help/--version打印用法后正常退出 / 打印版本后退出

平台相关选项:Windows 下支持--exit-pause--stop-on-desk-switch;X11 构建下支持--display <display>--no-xinitthreads;Wayland 场景下客户端默认使用 libei(见 ClientApp.cpp),可用--no-libei关闭。

主路径:连接服务器并反转滚动方向

最短命令是把服务器地址作为位置参数传入,--invert-scroll加在同一命令行即可:

# <server-address> 替换为服务器机器的地址,形式 [<hostname>][:<port>] deskflow-client <server-address> --invert-scroll

排查阶段建议加-f(前台运行,避免 daemon 化后看不到日志)和-l写日志文件;--yscroll仅在需要覆盖默认滚动增量 120 时使用:

# <server-address> 替换为服务器地址;<log-file> 替换为你希望写入的日志路径 deskflow-client -f -l <log-file> <server-address> --invert-scroll

两个参数的作用与内部落点:

  • --invert-scroll将 ClientArgs.h 中m_clientScrollDirection从默认的SERVER置为INVERT_SERVER(ArgParser.cpp),随后在创建客户端屏幕时传给平台屏幕实现(ClientApp.cpp 的createScreen),使本机滚动方向与服务器方向相反。
  • --host与本任务相反:它让客户端转为监听模式而不是主动连接,除非明确要反转主从角色,否则不要加。

结果验证与报错判断

命令行本身可以按以下方式核对:

  1. deskflow-client --help应打印上面列出的用法文本并正常退出,可用来核对当前构建支持哪些平台选项。
  2. 忘记传服务器地址时,ArgParser.cpp 会报错并退出:deskflow-client: a server address or name is required
  3. 传了拼写错误或不支持的选项时报deskflow-client: unrecognized option '<option>';选项缺参数值时报deskflow-client: missing arguments for '<option>'
  4. 参数解析行为有单元测试佐证:ClientArgsParsingTests.cpp 中parseClientArgs_setInvertScroll断言传入--invert-scrollm_clientScrollDirection == INVERT_SERVER

连接成功与否以客户端接入服务器后的实际表现为准:help 文本对该参数的定义是"invert scroll direction on this computer",即客户端机器上的滚动方向相对服务器方向被反转,滚动增量仍由--yscroll(默认 120)控制。

已知限制

  • Windows 下--daemon不受支持,解析器会直接报错并提示改用服务方式安装:the --daemon argument is not supported on windows. instead, install deskflow-client as a service (--service install)(ArgParser.cpp)。
  • Linux 上--enable-drag-drop会被解析器显式忽略并记录ignoring --enable-drag-drop, not supported on linux.
  • --invert-scroll影响的是客户端本机滚动方向;滚动增量、语言同步等仍是独立参数,互不替代。

图形界面上的滚动方向设置与此参数等价:GUI 侧勾选 "invert scroll direction" 后,CoreProcess.cpp 拼装启动参数时同样会追加--invert-scroll,命令行路径可以视为其等价的手动操作。

相关源码与文档

  • 用法与帮助文本:src/lib/deskflow/ClientApp.cpp
  • 参数解析:src/lib/deskflow/ArgParser.cpp
  • 客户端参数结构:src/lib/deskflow/ClientArgs.h
  • 客户端入口:src/apps/deskflow-client/deskflow-client.cpp
  • 服务器配置示例:doc/deskflow.conf.example
  • 构建流程:BUILD.md

【免费下载链接】synergy-coreShare a single keyboard and mouse between multiple computers.项目地址: https://gitcode.com/GitHub_Trending/sy/synergy-core

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询