• Linux下在编译时修改触摸板默认行为的方法


    接前篇文章《Linux下修改触摸板默认行为的方法、所遇问题及解决》,地址:

    Linux下修改触摸板默认行为的方法、所遇问题及解决_蓝天居士的博客-CSDN博客

    修改触摸板行为的方法找到了,但是如何能够在编译及生成镜像的时候就已经将70-synaptics.conf文件修改过来了,而不需要用户通过脚本或者GUI手动进行修改?

    为此,需要找到是哪个包中产生的70-synaptics.conf文件。在笔者的ubuntu22.04环境下,看一下/usr/share/X11/xorg.conf.d/目录下的内容,如下所示:

    1. $ ls /usr/share/X11/xorg.conf.d/
    2. 10-amdgpu.conf 10-quirks.conf 10-radeon.conf 40-libinput.conf 70-wacom.conf

    虽然没有看到70-synaptics.conf文件,但是有个70-wacom.conf文件。看名字也能知道,和synaptics是类似的。通过dpkg -S命令看一下它属于哪个包:

    1. $ dpkg -S /usr/share/X11/xorg.conf.d/
    2. xserver-xorg-core, xserver-xorg-input-wacom, xserver-xorg-input-libinput, xserver-xorg-video-amdgpu, xserver-xorg-video-radeon: /usr/share/X11/xorg.conf.d
    3. $ dpkg -S /usr/share/X11/xorg.conf.d/70-wacom.conf
    4. xserver-xorg-input-wacom: /usr/share/X11/xorg.conf.d/70-wacom.conf

    根据以上信息可以看到,70-wacom.conf属于xsever-xorg-input-wacom包。那么这个包又是通过哪个源码包安装的呢?我们需要在BLFS中寻找答案,见以下链接:

    https://www.linuxfromscratch.org/blfs/view/systemd/x/x7driver.html

    其页面下有这样一段内容:

    有人也许会问,你怎么知道是这个Xorg Wacom Driver生成的xsever-xorg-input-wacom包?你可以观察它的名字。前半部分是xserver-xorg,说明与xserver-xorg相关并且在其下;后半部分为input-wacom,这就能定位到页面中的具体位置了。

    至此,我们找到了70-wacom.conf文件对应的源码包。这就离70-synaptics.conf不远了。实际上wacom对应的是wacom公司的触摸板,那么显而易见地,synaptics对应的就是synaptics公司的触摸板了。

    仍然还是上面的链接:https://www.linuxfromscratch.org/blfs/view/systemd/x/x7driver.html

    在其中找到synaptics相关的内容,其实就在wacom的上边(笔者再贴图中留了个线索,仔细观察上边wacom的图会看到蛛丝马迹)。

    可以看到,产生70-synaptics.conf文件的源码包是xf86-input-synaptics-xx.xx.xx.tar.gz(其中:xx代表版本号)。

    下载对应的源码包,解压后内容如下:

    1. $ ls xf86-input-synaptics-1.9.2
    2. aclocal.m4 compile config.guess config.sub configure.ac depcomp INSTALL ltmain.sh Makefile.in missing src xorg-synaptics.pc.in
    3. ChangeLog conf config.h.in configure COPYING include install-sh Makefile.am man README.md tools

    在其中查找“70-synaptics”相关的内容:

    1. $ grep -rn "70-synaptics" ./xf86-input-synaptics-1.9.2
    2. ./xf86-input-synaptics-1.9.2/ChangeLog:234: conf: rename to 70-synaptics.conf
    3. ./xf86-input-synaptics-1.9.2/conf/Makefile.am:23:dist_config_DATA = 70-synaptics.conf
    4. ./xf86-input-synaptics-1.9.2/conf/Makefile.in:141:am__dist_config_DATA_DIST = 70-synaptics.conf
    5. ./xf86-input-synaptics-1.9.2/conf/Makefile.in:328:@HAS_XORG_CONF_DIR_TRUE@dist_config_DATA = 70-synaptics.conf
    6. ./xf86-input-synaptics-1.9.2/man/synaptics.man:926:.I ${sourcecode}/conf/70-synaptics.conf

    可以看到,70-synaptics文件位于config文件夹下。查看其内容:

    1. $ cat conf/70-synaptics.conf
    2. # Example xorg.conf.d snippet that assigns the touchpad driver
    3. # to all touchpads. See xorg.conf.d(5) for more information on
    4. # InputClass.
    5. # DO NOT EDIT THIS FILE, your distribution will likely overwrite
    6. # it when updating. Copy (and rename) this file into
    7. # /etc/X11/xorg.conf.d first.
    8. # Additional options may be added in the form of
    9. # Option "OptionName" "value"
    10. #
    11. Section "InputClass"
    12. Identifier "touchpad catchall"
    13. Driver "synaptics"
    14. MatchIsTouchpad "on"
    15. # This option is recommend on all Linux systems using evdev, but cannot be
    16. # enabled by default. See the following link for details:
    17. # http://who-t.blogspot.com/2010/11/how-to-ignore-configuration-errors.html
    18. # MatchDevicePath "/dev/input/event*"
    19. EndSection
    20. Section "InputClass"
    21. Identifier "touchpad ignore duplicates"
    22. MatchIsTouchpad "on"
    23. MatchOS "Linux"
    24. MatchDevicePath "/dev/input/mouse*"
    25. Option "Ignore" "on"
    26. EndSection
    27. # This option enables the bottom right corner to be a right button on clickpads
    28. # and the right and middle top areas to be right / middle buttons on clickpads
    29. # with a top button area.
    30. # This option is only interpreted by clickpads.
    31. Section "InputClass"
    32. Identifier "Default clickpad buttons"
    33. MatchDriver "synaptics"
    34. Option "SoftButtonAreas" "50% 0 82% 0 0 0 0 0"
    35. Option "SecondarySoftButtonAreas" "58% 0 0 15% 42% 58% 0 15%"
    36. EndSection
    37. # This option disables software buttons on Apple touchpads.
    38. # This option is only interpreted by clickpads.
    39. Section "InputClass"
    40. Identifier "Disable clickpad buttons on Apple touchpads"
    41. MatchProduct "Apple|bcm5974"
    42. MatchDriver "synaptics"
    43. Option "SoftButtonAreas" "0 0 0 0 0 0 0 0"
    44. EndSection

    这就是最终系统中的/usr/share/X11/xorg.conf.d/70-synaptics.conf文件。

    经过一番努力,文件找到了,如何自动向文件中添加需要的内容?利用sed命令。在这里假设需要事触摸板的默认行为变为轻触触摸板表示左键单击,则需要添加以下一行命令:

    sed -i '/This option is recommend on all Linux systems using evdev/i \ \ \ \ \ \ \ \ Option "TapButton1" "1"' ./conf/70-synaptics.conf

    完整的示例脚本如下:

    1. tar -xf xf86-input-synaptics-1.9.1.tar.bz2
    2. cd xf86-input-synaptics-1.9.1
    3. sed -i '/This option is recommend on all Linux systems using evdev/i \ \ \ \ \ \ \ \ Option "TapButton1" "1"' ./conf/70-synaptics.conf
    4. ./configure $XORG_CONFIG
    5. make -j32
    6. make install

    这样修改后,经过编译生成镜像并烧录,系统中的/usr/share/X11/70-synaptics.conf文件内容就是修改后的了,触摸板的默认行为就改变过来了。

  • 相关阅读:
    @FeignClient(contextId = “remoteLogService“, value = ServiceNameConstants.UPMS)
    ChatGLM3-6B安装
    Spring AOP实现原理及代理模式
    word实用小技能(肝论文必备)
    note++ 操作技巧
    rsync远程同步
    Git分支管理
    Android 扩大View可点击区域范围
    javascript 使用setInterval模拟计算程序读秒
    没用的知识增加了,尝试用文心实现褒义词贬义词快速分类
  • 原文地址:https://blog.csdn.net/phmatthaus/article/details/127802144