LoginSignup
3
5

More than 3 years have passed since last update.

Ubuntu 20.04 LTSでWacomペンタブのキー設定

Last updated at Posted at 2020-09-07

ペンタブの列挙

$ xsetwacom --list devices
Wacom Intuos BT M Pad pad           id: 11  type: PAD       
Wacom Intuos BT M Pen stylus        id: 12  type: STYLUS

設定の確認

$ xsetwacom --get "Wacom Intuos BT M Pen stylus" all
Option "Area" "0 0 21600 13500"
Button: Actions are not supported by xorg.conf. Try shell format (-s) instead.
Button: Actions are not supported by xorg.conf. Try shell format (-s) instead.
Button: Actions are not supported by xorg.conf. Try shell format (-s) instead.
Button: Actions are not supported by xorg.conf. Try shell format (-s) instead.
......

出力されてますが、ボタンの設定は--shell(-s)オプションをつけると表示されます。

$ xsetwacom -s --get "Wacom Intuos BT M Pen stylus" all
xsetwacom set "Wacom Intuos BT M Pen stylus" "Area" "0 0 21600 13500"
xsetwacom set "Wacom Intuos BT M Pen stylus" "Button" "1" "button +1 "
xsetwacom set "Wacom Intuos BT M Pen stylus" "Button" "2" "button +2 "
xsetwacom set "Wacom Intuos BT M Pen stylus" "Button" "3" "button +3 "
xsetwacom set "Wacom Intuos BT M Pen stylus" "Button" "8" "button +8 "
......

ボタンの設定は$ xsetwacom set DeviceName "Button" button-number mappingで設定できます。
manでも確認できます。manで確認してください。

ここからが本題です。
ペンタブを再接続するとこの設定は初期化されます。

設定の自動化

udevを使ってシェルスクリプトを実行します。ただし、ちょっと工夫します。
こちらの記事にもあるとおり、単にudevルールのRUNでコマンドを実行しても、そのタイミングではまだペンタブは接続されていないので設定は適用されません。sleepをしてもRUNの内容が完了するまで接続が完了しないので無効です。そこで、シェルスクリプトをバックグラウンドで実行し、その中でsleepすることで接続の完了を待ちます。

ここに書いてありました(笑)
https://unix.stackexchange.com/questions/65788/why-doesnt-xsetwacom-work-from-udev
日本語で解説してる記事がないので書いておこうと思います。

/etc/udev/rules.d/90-wacom.conf
ACTION=="add", SUBSYSTEMS=="input", ATTRS{name}=="Wacom Intuos BT M Pen", ENV{DISPLAY}=":0", ENV{XAUTHORITY}="/run/user/1000/gdm/Xauthority", RUN+="/usr/local/bin/wacom.sh"
/usr/local/bin/wacom.sh
#!/usr/bin/env bash
/usr/local/bin/wacom-post.sh &
/usr/local/bin/wacom-post.sh
#!/usr/bin/env bash
/usr/bin/sleep 2
export XAUTHORITY=/run/user/1000/gdm/Xauthority
export DISPLAY=:0
/usr/bin/xsetwacom --set "Wacom Intuos BT M Pen stylus" Button 2 key "ctrl z"

ここでは、ペンのキーにCtrl+Zを設定しています。
Ubuntuの設定からもペンのキーマッピングを指定できますが、マウスのボタンや戻る、進むくらいしか設定できないので。

3
5
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
3
5