やってみる

アウトプットすべく己を導くためのブログ。その試行錯誤すらたれ流す。

espansoをインストールする(TextExpander)

 入力補助ツール。キー入力に応じてテキストを展開したりスクリプト実行したりする。

情報源

手順

0. rustをインストールする

 以下コマンドが存在していればOK。

cargo --help

 なければ以下に従ってインストールする。

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

 以下のように横着しようとしたがダメだった。

$ cargo install espanso

    Updating crates.io index
error: could not find `espanso` in registry `https://github.com/rust-lang/crates.io-index` with version `*

1. ソースコードを入手する

  1. espansoから最新版のソースコードを入手する
wget https://github.com/federico-terzi/espanso/archive/v0.7.2.zip
unzip v0.7.2.zip
cd espanso-0.7.2

2. ビルドする

  1. ビルドに必要なソフトをインストールする
sudo apt update
sudo apt install -y cmake libxdo-dev

 manual-installationには以下をインストールせよとあった。

sudo apt install -y libxtst6 libxdo3 xclip libnotify-bin

 v0.7.3では以下も必要だった。

sudo apt install -y libssl-dev

ビルドエラーで判明した必要なもの

  --- stderr
  thread 'main' panicked at '
  failed to execute command: No such file or directory (os error 2)
  is `cmake` not installed?

  build script failed, must exit now', /home/pi/.cargo/registry/src/github.com-1285ae84e5963aae/cmake-0.1.42/src/lib.rs:861:5
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
  --- stderr
  In file included from /tmp/work/espanso-0.7.2/native/liblinuxbridge/bridge.cpp:21:
  /tmp/work/espanso-0.7.2/native/liblinuxbridge/fast_xdo.h:9:10: fatal error: xdo.h: そのようなファイルやディレクトリはありません
   #include <xdo.h>
            ^~~~~~~
  compilation terminated.
  make[2]: *** [CMakeFiles/linuxbridge.dir/build.make:63: CMakeFiles/linuxbridge.dir/bridge.cpp.o] エラー 1
  make[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/linuxbridge.dir/all] エラー 2
  make: *** [Makefile:130: all] エラー 2
  thread 'main' panicked at '
  command did not execute successfully, got: exit code: 2

  build script failed, must exit now', /home/pi/.cargo/registry/src/github.com-1285ae84e5963aae/cmake-0.1.42/src/lib.rs:861:5
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed

cargo build
...
    Finished dev [unoptimized + debuginfo] target(s) in 5m 31s

3. インストールする

cargo install --path .

cargo installだと怒られた

$ cargo install
error: Using `cargo install` to install the binaries for the package in current working directory is no longer supported, use `cargo install --path .` instead. Use `cargo build` if you want to simply build the package.

...
    Finished release [optimized] target(s) in 16m 54s
  Installing /home/pi/.cargo/bin/espanso
   Installed package `espanso v0.7.2 (/tmp/work/espanso-0.7.2)` (executable `espanso`)

4. 開始する

espanso start
espanso must be registered to systemd (user level) first. Do you want to proceed? [Y/n] 
Y
Entry will point to: /home/pi/.cargo/bin/espanso
Service file created correctly!
Enabling espanso for systemd...
Created symlink /home/pi/.config/systemd/user/default.target.wants/espanso.service → /home/pi/.config/systemd/user/espanso.service.
Service registered correctly!
Daemon started correctly!

 これで以降は自動起動してくれるはず。

5. 使ってみる

  1. 端末やテキストエディタ等で:espansoとキー入力する
  2. Hi there!と出力される

6. フォーム

 moduloをインストールする。

sudo apt install -y clang libwxgtk3.0-0v5 libwxgtk3.0-dev build-essential

wget https://github.com/federico-terzi/modulo/archive/v0.1.1.zip
unzip v0.1.1
cd modulo-0.1.1
cargo build --release
#cargo install --path .
sudo cp ./target/release/modulo /usr/bin/modulo
    Finished dev [unoptimized + debuginfo] target(s) in 3m 47s

form.yml

layout: |
  Hey {{name}},
  This form is built with modulo!
modulo form -i form.yml

f:id:ytyaru:20201017171256p:plain

{"name":"AAA"}

所感

 これをカスタマイズすれば入力が楽になりそう。

対象環境

$ uname -a
Linux raspberrypi 5.4.51-v7l+ #1333 SMP Mon Aug 10 16:51:40 BST 2020 armv7l GNU/Linux