van*_*ium 7 keyboard software-installation
有价值的键盘自动化工具xdotool在 Wayland 上不起作用。ydotool是一个模仿 xdotool 的一些功能的新工具,但它可以在 Xorg 和 Wayland 中使用。
ydotoolUbuntu 软件中心提供版本 0.1.8-3。与此同时,该工具已经被“重构”,即它已被完全重写,没有外部依赖项,并且使用更少的内存并且没有动态内存分配。因此,强烈建议使用当前版本。
github 上只提供了源代码,没有如何构建代码和安装工具的说明。我们如何安装ydotool 1.0.1。在Ubuntu上?
随着 Wayland 的出现,像xdotool为 Xorg 设计的自动化实用程序不再起作用。ydotool是一个独立于显示管理器工作的键盘自动化工具,即它可以在 Wayland 和 Xorg 上运行。
以下是我在 Ubuntu 22.04 上测试的安装说明。使用 cmake 的编译说明归功于此处。
1. 前提条件
1.1 确保您拥有编译所需的工具。
# Needed for compilation
sudo apt install cmake scdoc pkg-config
Run Code Online (Sandbox Code Playgroud)
1.2 在基于 Debian 的发行版中,checkinstall可用于将编译后的代码打包到.deb文件中,而不是将编译后的文件直接移动到系统目录中。这样,自定义编译的程序在包管理系统中是已知的,并且如果需要,可以轻松地再次删除。
# For generating an installable .deb file
sudo apt install checkinstall
Run Code Online (Sandbox Code Playgroud)
1.3 可选:安装git以从 git 克隆。或者,您可以.zip从 github 页面下载并解压该文件。
# Optional: git to clone the repository instead of downloading zip
sudo apt install git
Run Code Online (Sandbox Code Playgroud)
2.下载并编译
2.1 使用工具下载源码git。
git clone https://github.com/ReimuNotMoe/ydotool
Run Code Online (Sandbox Code Playgroud)
或者,从 github 页面下载并解压 zip 文件
2.2 编译
cd ydotool ## This will be `ydotool-master` if you extracted the zip file
mkdir build && cd build
cmake ..
make -j `nproc`
Run Code Online (Sandbox Code Playgroud)
3. 安装
可以在基于 Debian 的系统上使用,而不是传统地sudo make install将编译的文件安装到系统目录中。创建一个文件,然后可以使用 APT 包管理器安装该文件。因此,包管理系统知道该包,并且可以使用包管理器轻松地再次删除该包。checkinstallcheckinstall.deb
3.1 启动工具
sudo checkinstall
Run Code Online (Sandbox Code Playgroud)
3.2 接受提示上的默认答案
The package documentation directory ./doc-pak does not exist.
Should I create a default set of package docs? [y]:
Run Code Online (Sandbox Code Playgroud)
3.3 输入包的描述
Please write a description for the package.
End your description with an empty line or EOF.
>>
Run Code Online (Sandbox Code Playgroud)
例如:Keyboard automation utility - custom install
3.4 将包的名称更改为更有意义的名称:在提示符上
This package will be built according to these values:
Run Code Online (Sandbox Code Playgroud)
输入2将包名称更改为例如ydotool-custom。这样,以后就可以很容易地识别该包,并且不会与 Ubuntu 提供的包发生名称冲突。
n3.5 再次接受提示上的默认答案
Some of the files created by the installation are inside the home directory: /home
You probably don't want them to be included in the package.
Do you want me to list them? [n]:
Run Code Online (Sandbox Code Playgroud)
3.6 然而,回答y下一个问题
Should I exclude them from the package? (Saying yes is a good idea) [n]:
Run Code Online (Sandbox Code Playgroud)
尽管回答no并留下这些文件可能根本没有什么坏处。
之后,.deb将创建并自动安装。稍后可以使用命令重新安装它sudo apt install <path-to-debfile>。
4. 配置
4.1ydotool必须root运行。可能有更现代的方法允许用户在不使用 的情况下启动该实用程序,但老技巧是在可执行文件上sudo设置该位。suid
# Set the suid bit so ydotool can be run by any user
sudo chmod +s $(which ydotool)
Run Code Online (Sandbox Code Playgroud)
4.2 通过应用程序,安装了systemd服务。启用并安装它:
# Have the the newly installed service recognized, enabled and started
sudo systemctl daemon-reload
sudo systemctl enable ydotool
sudo service ydotool start
Run Code Online (Sandbox Code Playgroud)
ydotool4.3 守护程序需要通过其在 上进行通信的套接字/tmp/.ydotool_socket。当以用户身份运行时,ydotool查找/run/user/<uid>/.ydotool_socket. 人们可以建立一个到 的符号链接/tmp/.ydotool_socket。或者,您可以设置一个变量YDOTOOL_SOCKET来指示要使用的套接字。
~/.profile在文本编辑器中打开
添加行
export YDOTOOL_SOCKET=/tmp/.ydotool_socket
Run Code Online (Sandbox Code Playgroud)
5.测试是否有效
5.1 注销然后重新登录以使环境变量生效。
5.2 打开终端并使用以下命令进行测试:
ydotool type Ubuntu
Run Code Online (Sandbox Code Playgroud)
在提示符重新出现之前,应输入字母“Ubuntu”。