用 autoplank 在多个显示器上使用 Plank 扩展坞
Plank
![](/data/attachment/album/201911/16/161121nbbncrlxa5s5a5r5.png)


[autoplank](https://github.com/abiosoft/autoplank) 是用 Go 语言编写的小型工具，它为 Plank 扩展坞增加了多显示器支持，而无需创建[多个](https://answers.launchpad.net/plank/+question/204593)扩展坞。


当你将鼠标光标移动到显示器的底部时，`autoplank` 会使用 `xdotool` 检测到你的鼠标移动，并且自动将 Plank 扩展坞移动到该显示器。该工具仅在将 Plank 设置为在屏幕底部的情况下工作（至少目前如此）。


在 Plank 实际出现在鼠标所在的显示器上前会稍有延迟。开发人员说这是有意设计的，以确保你确实要在该显示器上访问 Plank。显示 Plank 之前的时间延迟目前尚不可配置，但将来可能会改变。


`autoplank` 可以在 elementary OS 以及其它的桌面环境或发行版上使用。


Plank 是一个简单的扩展坞，它显示了正在运行的应用程序/窗口的图标。它允许将应用程序固定到扩展坞，并带有一些内置的简单“扩展组件”：剪贴板管理器、时钟、CPU 监视器、显示桌面和垃圾桶。要访问其设置，请按住 `Ctrl` 键，同时右键单击 Plank 扩展坞上的任意位置，然后单击 “Preferences”。


Plank 默认用在 elementary OS 中，但也可以在任何桌面环境或 Linux 发行版中使用。


### 安装 autoplank


在其 GitHub 页面上，提到你需要 Go 1.8 或更高版本才能构建 `autoplank`，但我能够在 Ubuntu 16.04（elementary OS 0.4 Loki）中使用 Go 1.6 成功构建它。


开发者说：


1、安装所需的依赖项。


要构建 `autoplank`，你需要 Go（在 Debian、Ubuntu、elementary OS 等中使用 golang-go）。要获取最新的 Git 代码，你还需要 `git`，要在显示器上检测你的鼠标移动，还需要安装 `xdotool`。


使用以下命令将它们安装在 Ubuntu、Debian、elementary OS 等中：



```
sudo apt install git golang-go xdotool
```

2、从 [Git](https://github.com/abiosoft/autoplank) 获取最新的 `autoplank`，构建并将其安装在 `/usr/local/bin` 中：



```
git clone https://github.com/abiosoft/autoplank
cd autoplank
go build -o autoplank
sudo mv autoplank /usr/local/bin/
```

你现在可以从主目录中删除 `autoplank` 文件夹。


当你想卸载 `autoplank` 时，只需删除 `/usr/local/bin/autoplank` 二进制文件（`sudo rm /usr/local/bin/autoplank`）。


3、将 `autoplank` 添加到启动中。


如果你想在将 `autoplank` 添加到启动项或为其创建 systemd 服务之前尝试使用 `autoplank`，则只需在终端中键入 `/usr/local/bin/autoplank` 即可启动它。


要使 `autoplank` 在重新启动后起作用，你需要将其添加到启动项中。确切的操作步骤取决于你的桌面环境，因此我不会确切告诉你如何在每个桌面环境中执行此操作，但是请记住在启动项中将 `/usr/local/bin/autoplank` 设置为可执行文件。


在 elementary OS 中，你可以打开“系统设置”，然后在“应用程序”的“启动”选项卡上，单击窗口左下角的“+”按钮，然后在“键入自定义命令”字段中添加 “/usr/local/bin/autoplank”：


![](/data/attachment/album/201911/16/161130sxf5wox5fwcmdnlx.png)


如[此处](https://github.com/abiosoft/autoplank#optional-create-a-service)的解释，使用 `autoplank` 的另一种方法是通过为其创建 systemd 服务。将 systemd 服务用于 autoplank 的优点是，无论它出于何种原因而崩溃，都可以重新启动 `autoplank`。可以使用 systemd 服务或将 `autoplank` 添加到启动应用程序中（但不要同时使用两者）。


4、完成此操作后，注销、登录，`autoplank` 应该已在运行，因此你可以将鼠标移至显示器底部以将 Plank 停靠此处。




---


via: <https://www.linuxuprising.com/2018/08/use-plank-on-multiple-monitors-without.html>


作者：[Logix](https://plus.google.com/118280394805678839070) 选题：[lujun9972](https://github.com/lujun9972) 译者：[wxy](https://github.com/wxy) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
# Use Plank On Multiple Monitors Without Creating Multiple Docks With autoplank


[autoplank](https://github.com/abiosoft/autoplank)is a small tool written in Go which adds multi-monitor support to Plank dock without having to create[multiple](https://answers.launchpad.net/plank/+question/204593)docks.When you move your mouse cursor to the bottom of a monitor, autoplank detect your mouse movement using

`xdotool`

and it automatically moves Plank to that monitor. This tool only works if Plank is set to run at the bottom of the screen, at least for now.There's a slight delay until Plank actually shows up on the monitor where the mouse is though. The developer says this is intentional, to make sure you actually want to access Plank on that monitor. The time delay before showing plank is not currently configurable, but that may change in the future.

**[Edit] autoplank stopped working and a couple of pull requests on GitHub fix that, but the autoplank developer seems inactive and did not merge those pull requests, that's why in the commands below we'll also get those these**

[1](https://github.com/abiosoft/autoplank/pull/6)[2](https://github.com/abiosoft/autoplank/pull/7)pull requests besides the autoplank code. Although it works, autoplank is a bit buggy with these pull requests.The behavior also changes when including these pull requests. With these fixes, Plank is shown on a different monitor as soon as the mouse enters that monitor, with no delay. This causes Plank to flicker slightly (I didn't find it too distracting, but you may have a different opinion) when it's moved between monitors, if Plank is set to hide, in all modes except "Autohide". With "Autohide" this is not noticeable because the dock is only shown when moving the mouse near the bottom of the screen. It is very noticeable though if hiding Plank is completely turned off, so I don't recommend using autoplank if you want to keep Plank always visible!

**It's also important to note that with these 2 extra pull requests, the Plank preferences window closes when moving the mouse to a different monitor.**

autoplank should work with elementary OS, as well as any desktop environment or Linux distribution you use Plank dock on.

Plank is a simple dock that shows icons of running applications / windows. The application allows pinning applications to the dock, and comes with a few built-in simple "docklets": a clipboard manager, clock, CPU monitor, show desktop and trash. To access its settings, hold down the

`Ctrl`

key while right clicking anywhere on the Plank dock, and then clicking on `Preferences`

.Plank is used by default in elementary OS, but it can be used on any desktop environment or Linux distribution you wish.

## Install autoplank

On its GitHub page, it's mentioned that you need Go 1.8 or newer to build autoplank but I was able to successfully build it with Go 1.6 in Ubuntu 16.04 (elementary OS 0.4 Loki).

The developer has said on

**1. Install required dependencies.**

To build autoplank you'll need Go (

`golang-go`

in Debian, Ubuntu, elementary OS, etc.). To get the latest Git code you'll also need `git`

, and for detecting the monitor on which you move the mose, you'll also need to install `xdotool`

.Install these in Ubuntu, Debian, elementary OS and so on, by using this command:

`sudo apt install git golang-go xdotool`


**2. Get the latest autoplank from**

[Git](https://github.com/abiosoft/autoplank), build it, and install it in`/usr/local/bin`

.```
git clone https://github.com/abiosoft/autoplank
cd autoplank
git fetch origin pull/6/head:fixes
git fetch origin pull/7/head:fixes
git checkout fixes
go build -o autoplank
sudo mv autoplank /usr/local/bin/
```


You can remove the autoplank folder from your home directory now.

When you want to uninstall autoplank, simply remove the

`/usr/local/bin/autoplank`

binary (`sudo rm /usr/local/bin/autoplank`

).**3. Add autoplank to startup.**

If you want to try autoplank before adding it to startup or creating a systemd service for it, you can simply type

`autoplank`

in a terminal to start it.To have autoplank work between reboots, you'll need to add it to your startup applications. The exact steps for doing this depend on your desktop environments, so I won't tell you exactly how to do that for every desktop environment, but remember to use

`/usr/local/bin/autoplank`

as the executable in Startup Applications.In elementary OS, you can open

`System Settings`

, then in `Applications`

, on the `Startup`

tab, click the `+`

button in the bottom left-hand side corner of the window, then add `/usr/local/bin/autoplank`

in the `Type in a custom command`

field:The order in which Plank and autoplank are launched shouldn't matter.

**Another way of using autoplank is by creating a systemd service for it, as explained**Using a systemd service for autoplank has the advantage of restarting autoplank if it crashes for whatever reason. Use either the systemd service or add autoplank to your startup applications (don't use both).

[here](https://github.com/abiosoft/autoplank#optional-create-a-service).**4. After you do this, logout, login and autoplank should be running so you can move the mouse at the bottom of a monitor to move Plank dock there.**