我在 Ubuntu 18.04 ( Kernel: 4.15.0-72-generic
) 下使用 Wacom 绘图板。
不幸的是,我无法使用系统设置对其进行配置,因为它无法正确识别。
配置通过xsetwacom
工作,但不是持久的。只要我重新启动计算机或重新插入设备,就会加载默认设置。
我认为最简单的解决方案是在平板电脑被识别为 USB 设备后立即运行配置脚本。
根据我的理解,要做到这一点需要两个步骤:
创建 udev 规则
我创建了一个
/etc/udev/rules.d/99-config_wacom_intuos.rules
包含以下内容的文件:# "idVendor" and "idProduct" were derived from the output of the lsusb command. ACTION=="add" \ , SUBSYSTEM=="input" \ , KERNEL=="mouse*" \ , ATTRS{idVendor}=="1234" \ , ATTRS{idProduct}=="5678" \ , RUN+="/bin/sh -c '/usr/local/bin/config_wacom_intuos.sh >> /var/log/custom_logs/config_wacom_intuos.log 2>&1'"
该文件具有以下权限:
-rw-r--r-- 1 root root ...
(这本词典
/var/log/custom_logs
也是我创作的。)创建配置脚本
我创建了一个
/usr/local/bin/config_wacom_intuos.sh
包含以下内容的文件:#!/bin/bash #coding:utf8 # These were the missing statements as suggested by the answer. #export DISPLAY=:1 #export XAUTHORITY=/run/user/1000/gdm/Xauthority echo "`date '+%Y-%m-%dT%H:%M:%S'`, ShellPID $$, start" sleep 1 if xsetwacom --list devices | grep -q "Wacom Intuos BT" then main_screen="HEAD-0" bezier_args="0 20 80 100" positioning_mode="Absolute" raw_sample_lvl="9" suppress_lvl="10" # Maps the graphics tablet to the area of a specified screen (for multiple-screen environments). xsetwacom set "Wacom Intuos BT S Pen stylus" MapToOutput "$main_screen" xsetwacom set "Wacom Intuos BT S Pen eraser" MapToOutput "$main_screen" xsetwacom set "Wacom Intuos BT S Pen cursor" MapToOutput "$main_screen" # Changes the pressure sensitivity. xsetwacom set "Wacom Intuos BT S Pen stylus" PressureCurve "$bezier_args" xsetwacom set "Wacom Intuos BT S Pen eraser" PressureCurve "$bezier_args" # Smoothes drawn lines by reducing any quivering. xsetwacom set "Wacom Intuos BT S Pen stylus" RawSample "$raw_sample_lvl" xsetwacom set "Wacom Intuos BT S Pen stylus" Suppress "$suppress_lvl" xsetwacom set "Wacom Intuos BT S Pen eraser" RawSample "$raw_sample_lvl" xsetwacom set "Wacom Intuos BT S Pen eraser" Suppress "$suppress_lvl" xsetwacom set "Wacom Intuos BT S Pen cursor" RawSample "$raw_sample_lvl" xsetwacom set "Wacom Intuos BT S Pen cursor" Suppress "$suppress_lvl" # Specifies the positioning mode ("Absolute" / "Relative") xsetwacom set "Wacom Intuos BT S Pen stylus" Mode "$positioning_mode" xsetwacom set "Wacom Intuos BT S Pen eraser" Mode "$positioning_mode" xsetwacom set "Wacom Intuos BT S Pen cursor" Mode "$positioning_mode" # Assigns actions to the tablet buttons. xsetwacom set "Wacom Intuos BT S Pad pad" Button 1 "key +ctrl z -ctrl" xsetwacom set "Wacom Intuos BT S Pad pad" Button 2 "key +ctrl +shift z -ctrl -shift" xsetwacom set "Wacom Intuos BT S Pad pad" Button 3 "key 0xffab" xsetwacom set "Wacom Intuos BT S Pad pad" Button 8 "key 0xffad" else echo "NO 'WACOM INTUOS BT' DEVICES FOUND." fi echo "`date '+%Y-%m-%dT%H:%M:%S'`, ShellPID $$, end" echo -e "---\n" exit 0
该文件具有以下权限:
-rwxr-xr-x 1 root root ...
当我从终端手动执行脚本时,它工作得很好。
当我插入设备时它也会执行。不幸的是,这似乎没有任何效果。
此外,该脚本在插入设备后会连续执行多次。
我认为这种行为是由于 udev 规则而发生的,该规则的限制性不够。
谁能告诉我,我做错了什么?