关于macos:Synergycore-编译-使用-教程

34次阅读

共计 7420 个字符,预计需要花费 19 分钟才能阅读完成。

Synergy

如果你平时同时两台或多台电脑,你是如何他们之间合作的,又是如何共享文件的呢?

诚然我晓得 Windows 官网出品的鼠标有 无界 性能。提供文件共享的服务有很多。而明天我想介绍的 Synergy,让一般键鼠就能跨屏幕操作,还能复制粘贴文字,图片等。而且还不受平台限度,只两台桌面电脑 ip 互联互通。

无界鼠标因为是微软出品的,所以只反对 Windows 平台,安装包也是 MSI 文件格式。

Synergy是一个跨平台的 鼠标、键盘、剪切板共享软件,反对 Windows,Mac,Linux 支流桌面平台。也就是说你能够用连贯在 Mac 电脑上键鼠,操作旁边的 Windows 电脑。

官网:https://symless.com/synergy

开源地址:https://github.com/symless/synergy-core

下载

GUI 版程序只能官网付费上下载,没有登陆App Store, 还有点须要留神 1.8.8 及以前的版本都是 32 位的程序,所以这次来折腾下 64 位的开源版。

Mac OS Cotalina 开始,就齐全不能运行 32 位的程序了

装置

如果是官网下载 Synergy GUI 版,那双击就完事了。

编译

这里说下 github 上开源的 core 版本,编译,装置。

Mac OS 编译

装置依赖,编译软件,编译,装置:

# Install Homebrew

## 装置相干编译软件
$ brew install cmake
$ brew install qt
$ brew install openssh
$ brew install git

## 查看 qt 装置信息,以及目录,等下须要用到 /usr/local/Cellar/qt/5.15.0/Frameworks/
$ brew info qt

## 增加一个环境变量
$ export CMAKE_PREFIX_PATH="/usr/local/Cellar/qt/5.15.0/Frameworks/"

# 下载源码并进入源码目录
$ git clone https://github.com/symless/synergy-core.git
$ cd synergy-core
$ mkdir build
$ cd build
## 筹备编译参数
$ cmake -DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk  -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 -DCMAKE_OSX_ARCHITECTURES=x86_64 
## 编译
make

Windows 编译

$ cd Projects\synergy
$ mkdir build
$ cd build
$ call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
$ cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=Debug ..
$ msbuild synergy-core.sln /p:Platform="x64" /p:Configuration=Debug /m
$ cd ..
$ copy ext\openssl\windows\x64\bin\* build\

Linux 编译

$ cd Projects/synergy
$ mkdir build
$ cd build
$ cmake ..
$ make

编译胜利,会生成 3 个可执行文件。编辑后产物在:

./synergy-core/build/bin/

可执行文件

synergy-core

命令行程序:synergy-core, synergyc, synergys.

Synergy Core v1.x

对于 1.x 版本,client,server 是两个程序,也就是别离对应:synergyc,synergys。

OS Command
Windows synergyc [server IP]
macOS ./synergyc [server IP]
Linux ./synergyc [server IP]
OS Command
Windows synergys -c [path to config file]
macOS ./synergys -c [path to config file]
Linux ./synergys -c [path to config file]

Synergy Core v2.x

v2.x,server,client 都是一个程序了,通过不同的命令来确定本人的职责。

OS Command
Windows synergy-core --client [server IP]
macOS ./synergy-core --client [server IP]
Linux ./synergy-core --client [server IP]
OS Command
Windows synergy-core --server -c [path to config file]
macOS ./synergy-core --server -c [path to config file]
Linux ./synergy-core --server -c [path to config file]

Command help

通过一下命令:

$ ./synergyc --help
$ ./synergys --help

你能获取 v1.x synergy 的帮忙信息,然而 v2.x 不晓得是不是忘了把这个加上。

$ ./synergy-core --help     ## 不会显示帮忙信息

所以我就把它应有的帮忙信息放这里了。

Options for synergy-core --client

Usage: synergy-core --client [--yscroll <delta>] [--daemon|--no-daemon] [--name <screen-name>] [--restart|--no-restart] [--debug <level>] <server-address>

Connect to a synergy mouse/keyboard sharing server.

  -d, --debug <level>      filter out log messages with priority below level.
                             level may be: FATAL, ERROR, WARNING, NOTE, INFO,
                             DEBUG, DEBUG1, DEBUG2.
  -n, --name <screen-name> use screen-name instead the hostname to identify
                             this screen in the configuration.
  -1, --no-restart         do not try to restart on failure.
*     --restart            restart the server automatically if it fails.
  -l  --log <file>         write log messages to file.
      --no-tray            disable the system tray icon.
      --enable-drag-drop   enable file drag & drop.
  -f, --no-daemon          run in the foreground.
*     --daemon             run as a daemon.
      --yscroll <delta>    defines the vertical scrolling delta, which is
                             120 by default.
  -h, --help               display this help and exit.
      --version            display version information and exit.

* marks defaults.

The server address is of the form: [<hostname>][:<port>].  The hostname
must be the address or hostname of the server.  The port overrides the
default port, 24800.

Options for synergy-core --server

Usage: synergy-core --server [--address <address>] [--config <pathname>] [--daemon|--no-daemon] [--name <screen-name>] [--restart|--no-restart] [--debug <level>]

Start the synergy mouse/keyboard sharing server.

  -a, --address <address>  listen for clients on the given address.
  -c, --config <pathname>  use the named configuration file instead.
  -d, --debug <level>      filter out log messages with priority below level.
                             level may be: FATAL, ERROR, WARNING, NOTE, INFO,
                             DEBUG, DEBUG1, DEBUG2.
  -n, --name <screen-name> use screen-name instead the hostname to identify
                             this screen in the configuration.
  -1, --no-restart         do not try to restart on failure.
*     --restart            restart the server automatically if it fails.
  -l  --log <file>         write log messages to file.
      --no-tray            disable the system tray icon.
      --enable-drag-drop   enable file drag & drop.
  -f, --no-daemon          run in the foreground.
*     --daemon             run as a daemon.
  -h, --help               display this help and exit.
      --version            display version information and exit.

* marks defaults.

The argument for --address is of the form: [<hostname>][:<port>].  The
hostname must be the address or hostname of an interface on the system.
The default is to listen on all interfaces.  The port overrides the
default port, 24800.

If no configuration file pathname is provided then the first of the
following to load successfully sets the configuration:
  $HOME/.synergy.conf
  /etc/synergy.conf

配置

GUI 的配置就不讲了,这里说下 cli 程序的配置。

原文在这里 Synergy Text Config,我这里简略提一下。而后依照我给的模版来改改就能用,须要非凡定制可看看官网 wiki,或者留言问我。

Synergy 的配置文件根本格局:

section: ''name''
    ''args''
end

配置类型有 4 大类:

  • screens
  • aliases
  • links
  • options

aliases

定义 host name 和 屏幕命名的关系。

那么如何获取 host name 呢?

mac os 环境下:

$ hostname
## 或者
$ echo $HOSTNAME

screens

定义咱们的屏幕,命名,以及在操作各个屏幕时,是否响应一些非凡按键。

Windows,Linux,Mac 都有各自的非凡按键,如 win, command, meta 按键等,如果不是跨平台,都不须要做非凡解决。

links

定义各个屏幕之间的排列方位,这个很重要。

{left|right|up|down}[<range>] = name[<range>]

对于 range 参数就比拟有意思了,合理配置可是下如下成果。

section: links
     moe:
         right        = larry
         up(50,100)   = curly(0,50)
     larry:
         left         = moe
         up(0,50)     = curly(50,100)
     curly:
         down(0,50)   = moe
         down(50,100) = larry(0,50)
 end

实现了:

#       +-----------+  
#       |   curly   |  
#       |           | 
#       +-----------+ 
# +----------+ +----------+
# |    moe   | |  larry   | 
# |          | |          | 
# +----------+ +----------+ 

也就是在 curly 屏幕时,鼠标往左下滑,会滑到 moe 屏幕,往右下滑,会滑到 larray 屏幕。

options

其余选项,例如定义心跳距离,屏幕切换粘连工夫,

配置样例

好的还是来一个大而全的配置文件例子吧。

启动一个 Synergy-core server,配置文件是必须的!

Example textual configuration file
This example comes from doc/synergy-basic.conf

# sample synergy configuration file
#
# comments begin with the # character and continue to the end of
# line.  comments may appear anywhere the syntax permits.
# +----------+  +---------+ +---------+
# | mac-mini |  | macbook | | windows |
# |          |  |         | |         |
# +----------+  +---------+ +---------+

section: screens
    # three hosts named:  mac-mini, macbook, and windows
    # These are the nice names of the hosts to make it easy to write the config file
    # The aliases section below contain the "actual" names of the hosts (their hostnames)
    mac-mini:
    macbook:
    windows:
end

section: links
    # windows is to the right of macbook
    # mac-mini is to the left of macbook
    macbook:
        right(0,100) = windows # the numbers in parentheses indicate the percentage of the screen's edge to be considered active for switching)
        left  = mac-mini
        # shift = shift (shift, alt, super, meta can be mapped to any of the others)

    # macbook is to the right of mac-mini
    mac-mini:
        right = macbook

    # macbook is to the left of windows
    windows:
        left  = macbook
end

section: aliases
    # The "real" name of windows is John-Smiths-windows-3.local. 
    # If we wanted we could remove this alias and instead use John-Smiths-windows-3.local everywhere windows is above. 
    # Hopefully it should be easy to see why using an alias is nicer
    macbook:
        Pauls-MBP.local
    mac-mini:
        jumei-deMac-xp-mini.local
end

section: options
    switchDelay = 400   # 鼠标滑到边缘时,提留多久能力切换屏幕
    clipboardSharing = true # 共享剪切板
    clipboardSharingSize = 10000    # 剪切板共享字节大小限度,单位:千字节
end

启动

## 启动服务端
$ ./synergy-core --server --address 172.20.50.25:24800 --no-daemon --name macbook --config ./synergy.conf

## 启动其中一个客户端
$ ./synergy-core --client --no-daemon --name mac-mini 172.20.50.25:24801

常见问题

问题 1:FATAL: An error occurred: assistive devices does not trust this process, allow it in system settings.

这是应为你运行命令行程序调用了零碎的敏感接口,所有报错了。你须要给这个命令行软件授予权限.

也就是说,你用 iTerm 运行 Synergy-core,就给 iTerm 受权,你用零碎 terminal 运行的就给 terminal 受权。

我用的 Mac,就在 零碎偏好设置 > 安全性隐衷 > 隐衷 为其配置上。

如果是第一次受权,个别会有个弹窗,你依照弹框点进去就行了。

问题 2: synergy-core[66198:16759205] pid(66198)/euid(501) is calling TIS/TSM in non-main thread environment, ERROR : This is NOT allowed. Please call TIS/TSM in main thread!!!

你是不是还启动 Synergy GUI 程序,把它关掉就好了。

总结

synergy-core 程序用着还不错,尽管配置麻烦了一点,不过鼠标,键盘映射都没问题,复制粘贴(图片都能跨屏幕传)也都失常。不过还没试过跨 macos,windows 应用过。试了再回来

参考

  • https://github.com/symless/sy…
  • https://my.oschina.net/k4nz/b…
  • https://apple.macx.cn/thread-…

正文完
 0