AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-1030564

AFoeee's questions

Martin Hope
AFoeee
Asked: 2020-01-04 11:22:06 +0800 CST

如何在连接 Wacom 数位板后立即运行配置脚本(通过 USB)?

  • 4

我在 Ubuntu 18.04 ( Kernel: 4.15.0-72-generic ) 下使用 Wacom 绘图板。

不幸的是,我无法使用系统设置对其进行配置,因为它无法正确识别。

配置通过xsetwacom工作,但不是持久的。只要我重新启动计算机或重新插入设备,就会加载默认设置。


我认为最简单的解决方案是在平板电脑被识别为 USB 设备后立即运行配置脚本。

根据我的理解,要做到这一点需要两个步骤:

  1. 创建 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也是我创作的。)

  2. 创建配置脚本

    我创建了一个/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 规则而发生的,该规则的限制性不够。

谁能告诉我,我做错了什么?

automation bash wacom udev 18.04
  • 1 个回答
  • 1586 Views
Martin Hope
AFoeee
Asked: 2020-01-03 12:29:32 +0800 CST

如何使用 xsetwacom 将“鼠标滚轮向上/向下”映射到 Wacom 数位板的快捷按钮?

  • 3

我在 Ubuntu 18.04 下使用带有 4 个可编程快速按钮的“Wacom Intuos”图形输入板。所述计算机具有2个屏幕。

我喜欢将图形输入板的两个按钮分配给“鼠标滚轮向上”和“鼠标滚轮向下”操作。我的目标是在没有鼠标的情况下启用缩放。

因此我决定...

  • ...数位板组件的名称。

    # get a list of the tablet components
    xsetwacom --list devices
    
    Wacom Intuos BT S Pad pad          id: 12   type: PAD
    Wacom Intuos BT S Pen stylus       id: 13   type: STYLUS
    Wacom Intuos BT S Pen eraser       id: 14   type: ERASER
    Wacom Intuos BT S Pen cursor       id: 15   type: CURSOR
    
  • ...鼠标动作的数字表示。

    # Show mouse events
    xev -event button
    
    # mouse wheel down
    ButtonPress event ... button 4, ...
    ButtonRelease event ... button 4, ...
    
    # mouse wheel up
    ButtonPress event, ... button 5, ...
    ButtonRelease event, ... button 5, ...
    


在我的理解中,以下命令应该将“鼠标滚轮”动作分配给图形输入板的第三个按钮。不幸的是,情况似乎并非如此。

xsetwacom set "Wacom Intuos BT S Pad pad" Button 3 4

# I also tried:
xsetwacom set "Wacom Intuos BT S Pad pad" Button 3 "button 4"

该答案指出,引用快速按钮的数值是:1、3、8、9(从左到右)。
我的平板电脑型号不是这种情况。Button 1,Button 2并Button 3映射到数位板的第一个、第二个和第三个按钮。(至少我的测试表明了这一点。)


此命令是 bash 脚本的一部分:

#!/bin/bash
#coding:utf8

main_screen="HEAD-0"
bezier_args="0 20 80 100"
positioning_mode="Absolute"

# 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"

# 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"

# 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"

# 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 4

exit 0


谁能告诉我,我做错了什么?

shortcut-keys tablet wacom graphics-tablet 18.04
  • 1 个回答
  • 2536 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve