我使用 Linux Manjaro Gnome X11。我喜欢对鼠标按钮进行特殊设置,这是通过xinput
.
为了使此设置在会话中保持不变,我编写了xinput
in ~/.xprofile
,实际上它在每个会话开始时都有效。
但是,它会在给定会话内经过一段时间后停止工作(不注销)。
~/.config/autostart/*.desktop
可以使用Gnome 启动项 ( ) 来代替~/.xprofile
。
alba@mac2011-manjaro% journalctl -b _UID=1000 -t /usr/lib/gdm-x-session|grep Logitech
Mar 12 23:04:55 mac2011-manjaro /usr/lib/gdm-x-session[15562]: (II) event5 - Logitech M350: device removed
Mar 12 23:04:55 mac2011-manjaro /usr/lib/gdm-x-session[15562]: (II) config/udev: removing device Logitech M350
Mar 12 23:04:55 mac2011-manjaro /usr/lib/gdm-x-session[15562]: (II) config/udev: removing device Logitech M350
Mar 12 23:04:55 mac2011-manjaro /usr/lib/gdm-x-session[15562]: (II) config/udev: Adding input device Logitech M350 (/dev/input/mouse0)
Mar 12 23:04:55 mac2011-manjaro /usr/lib/gdm-x-session[15562]: (**) Logitech M350: Applying InputClass "system-keyboard"
Mar 12 23:04:55 mac2011-manjaro /usr/lib/gdm-x-session[15562]: (II) config/udev: Adding input device Logitech M350 (/dev/input/event5)
Mar 12 23:04:55 mac2011-manjaro /usr/lib/gdm-x-session[15562]: (**) Logitech M350: Applying InputClass "evdev pointer catchall"
Mar 12 23:04:55 mac2011-manjaro /usr/lib/gdm-x-session[15562]: (**) Logitech M350: Applying InputClass "evdev keyboard catchall"
Mar 12 23:04:55 mac2011-manjaro /usr/lib/gdm-x-session[15562]: (**) Logitech M350: Applying InputClass "libinput pointer catchall"
Mar 12 23:04:55 mac2011-manjaro /usr/lib/gdm-x-session[15562]: (**) Logitech M350: Applying InputClass "libinput keyboard catchall"
Mar 12 23:04:55 mac2011-manjaro /usr/lib/gdm-x-session[15562]: (**) Logitech M350: Applying InputClass "system-keyboard"
Mar 12 23:04:55 mac2011-manjaro /usr/lib/gdm-x-session[15562]: (II) Using input driver 'libinput' for 'Logitech M350'
Mar 12 23:04:55 mac2011-manjaro /usr/lib/gdm-x-session[15562]: (**) Logitech M350: always reports core events
Mar 12 23:04:55 mac2011-manjaro /usr/lib/gdm-x-session[15562]: (II) event5 - Logitech M350: is tagged by udev as: Keyboard Mouse
Mar 12 23:04:55 mac2011-manjaro /usr/lib/gdm-x-session[15562]: (II) event5 - Logitech M350: device is a pointer
Mar 12 23:04:55 mac2011-manjaro /usr/lib/gdm-x-session[15562]: (II) event5 - Logitech M350: device is a keyboard
Mar 12 23:04:55 mac2011-manjaro /usr/lib/gdm-x-session[15562]: (II) event5 - Logitech M350: device removed
Mar 12 23:04:55 mac2011-manjaro /usr/lib/gdm-x-session[15562]: (II) libinput: Logitech M350: needs a virtual subdevice
Mar 12 23:04:55 mac2011-manjaro /usr/lib/gdm-x-session[15562]: (II) XINPUT: Adding extended input device "Logitech M350" (type: MOUSE, id 14)
Mar 12 23:04:55 mac2011-manjaro /usr/lib/gdm-x-session[15562]: (**) Logitech M350: (accel) selected scheme none/0
Mar 12 23:04:55 mac2011-manjaro /usr/lib/gdm-x-session[15562]: (**) Logitech M350: (accel) acceleration factor: 2.000
Mar 12 23:04:55 mac2011-manjaro /usr/lib/gdm-x-session[15562]: (**) Logitech M350: (accel) acceleration threshold: 4
Mar 12 23:04:55 mac2011-manjaro /usr/lib/gdm-x-session[15562]: (II) event5 - Logitech M350: is tagged by udev as: Keyboard Mouse
Mar 12 23:04:55 mac2011-manjaro /usr/lib/gdm-x-session[15562]: (II) event5 - Logitech M350: device is a pointer
Mar 12 23:04:55 mac2011-manjaro /usr/lib/gdm-x-session[15562]: (II) event5 - Logitech M350: device is a keyboard
Mar 12 23:04:55 mac2011-manjaro /usr/lib/gdm-x-session[15562]: (**) Logitech M350: Applying InputClass "evdev pointer catchall"
Mar 12 23:04:55 mac2011-manjaro /usr/lib/gdm-x-session[15562]: (**) Logitech M350: Applying InputClass "evdev keyboard catchall"
Mar 12 23:04:55 mac2011-manjaro /usr/lib/gdm-x-session[15562]: (**) Logitech M350: Applying InputClass "libinput pointer catchall"
Mar 12 23:04:55 mac2011-manjaro /usr/lib/gdm-x-session[15562]: (**) Logitech M350: Applying InputClass "libinput keyboard catchall"
Mar 12 23:04:55 mac2011-manjaro /usr/lib/gdm-x-session[15562]: (**) Logitech M350: Applying InputClass "system-keyboard"
Mar 12 23:04:55 mac2011-manjaro /usr/lib/gdm-x-session[15562]: (II) Using input driver 'libinput' for 'Logitech M350'
Mar 12 23:04:55 mac2011-manjaro /usr/lib/gdm-x-session[15562]: (**) Logitech M350: always reports core events
Mar 12 23:04:55 mac2011-manjaro /usr/lib/gdm-x-session[15562]: (II) libinput: Logitech M350: is a virtual subdevice
Mar 12 23:04:55 mac2011-manjaro /usr/lib/gdm-x-session[15562]: (II) XINPUT: Adding extended input device "Logitech M350" (type: KEYBOARD, id 15)
是什么破坏了我的设置?如何使其在会话期间完全持久?
答案1
低级解决方案:我设置了一个无限循环的后台作业。
alba@mac2011-manjaro% cat ~/.xprofile
# This file is read at X11 start.
# In Fedora use ~/.config/autostart/*.desktop instead.
# # avoid spurious paste while scrolling
# # find the device number
# # repeat forever
while sleep 1
do xinput list|grep pointer|tail -1|grep -o 'id=[0-9]*'|grep -o '[0-9]*'|xargs -I{} xinput set-button-map {} 1 3 2
done&
这是无法完成的,crontab
因为 cron 作业无法连接到 X 服务器(而且一分钟也太短了)。