0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Arch更新で自作仮想マウスが死んだ話:原因はlibinputの機能分離だった

0
Posted at

概要

  • 何が起こった。
    ラップトップのタッチパッドで右クリック長押しをできるようにするだけのツールholdownが以下のエラーを出して動かなくなってしまった。
sudo holdown
# input device not found
  • 原因
    原因はlibinputのCLI機能がlibinput-toolsに分離されたことで、入力デバイスを列挙する libinput list-devices が動かなくなってしまったことである。

  • 解決策
    以下を実行す。
sudo pacman -S libinput-tools

これによってlibinputのcliコマンドが使えるようになり解決した。
他にも sudo libinput debug-events も再び使えるようになった

問題発見の手順

  • sudo holdown がコケる
  • sudo libinput debug-events が動かない
  • /usr/bin/libinput が存在しない
  • libinput-toolsというそれっぽいものインストールして解決

再発防止のために

  • holdownのエラーメッセージが貧弱
    入力デバイスを発見に失敗した場合、libinputが存在しないことや権限がないことで発見できなかったとしても一律で input device not found というエラーメッセージを出していた
async fn find_touchpad_event() -> Option<String> {
    let output = Command::new("libinput")
        .arg("list-devices")
        .output()
        .await
        .ok()?;//ここで失敗してもただNoneが返るのみ

    let stdout = String::from_utf8_lossy(&output.stdout);

    for line in stdout.lines() {
        if line.contains("Device:") && line.contains("Touchpad") {
            println!("{}",line);
            if let Some(next_line) = stdout.lines().skip_while(|l| *l != line).nth(1) {
                println!("{}",next_line);
                if let Some(path) = next_line.trim().strip_prefix("Kernel:") {
                    println!("{}",path);
                    return Some(path.trim().to_string());
                }
            }

        }
    }
    None
    //タッチパッドがなかったときもlibinputがなかったとき同様にNoneを返す
}

そんなわけでResult型でエラー内容を返答できるように改良を加えた

学んだこと

どこで止まったか分かるちゃんとしたエラーメッセージを出すようにすると原因がわかりやすいのでやる。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?