1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Manjaro Linuxでキーバインドをマウスボタンに割り当てる

Posted at

やりたいこと

5ボタンマウスの[戻る]ボタンにSuper+Tabのキーバインドを割り当てたい

環境

Manjaro Linux 22.1.0 Talos

必要なパッケージのインストール

$ sudo pacman -S xorg-xev
$ sudo pacman -S xbindkeys
$ yay -S xvkbd

設定に必要な情報の確認

設定をしていく上で必要になる情報をあらかじめ確認しておく

マウスボタンの確認

まずは、キーバインドを割り当てたいマウスボタンのボタン番号を確認する。

$ xev -event button | grep button

新しくウィンドウが開くので、そのウィンドウ上にマウスカーソルを乗せた状態で、マウスのボタンをクリック。
すると対応するボタン番号がターミナル上に表示される。

state 0x0, button 8, same_screen YES
state 0x0, button 8, same_screen YES

今回キーバインドを割り当てたいボタンはbutton 8

キーの確認

次に、割り当てたいキーボードのキーコードを確認する
以下のコマンドを実行すると、また新しいウィンドウが開くので、その状態でキーコードを確認したいキーを押下する。

$ xbindkeys --key

結果は以下の通り

Super
Press combination of keys or/and click under the window.
You can use one of the two lines after "NoCommand"
in $HOME/.xbindkeysrc to bind a key.
"(Scheme function)"
    m:0x40 + c:133
    Mod4 + Super_L
Tab
Press combination of keys or/and click under the window.
You can use one of the two lines after "NoCommand"
in $HOME/.xbindkeysrc to bind a key.
"(Scheme function)"
    m:0x0 + c:23
    Tab

SuperのキーコードはSuper_L
TabのキーコードはTab
だとわかった

設定ファイルの編集

まずは設定ファイルを作成する

$ touch ~/.xbindkeysrc

先程の確認から、割り当てたいキーコードはSuper_LTab、ターゲットのマウスボタンはbutton 8なので、以下の内容を書き込む

~/.xbindkeysrc
"xvkbd -text "\[Super_L]\[Tab]""
  m:0x0 + b:8

設定の反映

下記コマンドでxbindkeysを実行

$ xbindkeys

~/.xbindkeysrcを修正して変更を反映したいときは以下のコマンドを実行

$ pkill -f xbindkeys
$ xbindkeys

変更の永続化

このままでは起動するたびにリセットされてしまうので、~/.xprofile~/.xinitrcファイルに以下を記載する。
今回は~/.xprofileに記載した。

xbindkeys

以上で設定が完了。

参考

1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?