xremap導入

xremapからいれるのがいいかな? AURにxremapがない? xremap/xremap: Key remapper for X11 and Wayland 公式ページからinstall方法を確認。 cargoでインストールするのが良いよう。

cargo install xremap --features hypr

エラー発生。

error: rustup could not choose a version of cargo to run, because one wasn't specilflied explicitly, and no default 1s configured.
help: run 'rustup default stable' to download the latest stable release of Rust and set it as your default toolchain.

rustupでcargoを使えるようにする。

rustup default stable

再度実行。

cargo install xremap --features hypr

パスが通っていないので.zshrcにパスを通す。

# .zshrc
+export PATH="$HOME/.cargo/bin:$PATH"

再度実行。

xremap ~/.config/xremap/config.yml

failed to prepare input devices エラー発生。

uinputデバイスへのアクセス権が足りないので、ユーザーをinputグループに追加する。

sudo gpasswd -a $USER input

udevルールも確認・追加。

echo 'KERNEL=="uinput", GROUP="input", TAG+="uaccess"' | sudo tee /etc/udev/rules.d/input.rules
sudo udevadm control --reload-rules
sudo udevadm trigger

その後再ログイン。

今度は以下のエラー発生。

thread 'main' (194613) panicked at /home/morikawa/.cargo/registry/src/index.crates.i0-1949cf8c6b5b557f/hypriland-0.3.13/src/data/regular.rs:31:19:
A error occured while parsing the output from the hypr socket: IoError(0s { code: 2, kind: NotFound, message: "No such file or directory" })
note: run with “RUST_BACKTRACE=1" environment variable to display a backtrace

xremapで使っているhyprlandソケットのバージョンが古いので、手動インストール+バージョン変更で対策する。

cd ~/projects/
git clone git@github.com:xremap/xremap.git

Cargo.toml を開き、hyprlandのバージョンを 0.4.0-bata.3 にする。

インストールする。

rm Cargo.lock
cargo install xremap --features hypr --force --path .

無事動作した。

自動起動させたい

どうせxremapを使うなら自動で起動できるようにしたいので、設定する。

やってだめだったこと

systemd登録

systemdのserviceに登録する方法を試してみたが、だめだった。 以下の内容を~/.config/systemd/user/xremap.serviceに追加してみたが、起動はしているが動作しないという状態になった。

[Unit]
Description=Xremap
After=graphical-session.target
 
[Service]
ExecStart=/home/morikawa/.cargo/bin/xremap --watch=device %h/.config/xremap/config.yml
Restart=always
StandardOutput=journal
StandardError=journal
 
[Install]
WantedBy=default.target

成功パターン

hyprexecとhypridle記入

~/.config/hypr/custom/execs.conf~/.config/hypr/hypridle.conf に追記。

# exec.conf
+exec-once=~/.cargo/bin/xremap ~/.config/xremap/config.yml
# hypridle.conf
+after_sleep_cmd = "hyprctl dispatch dpms on ; pkill xremap ; (sleep 2; /home/morikawa/.cargo/bin/xremap --watch /home/morikawa/.config/xremap/config.yml &)" # to avoid having to press a key twice to turn on the display.