由于我使用的是 16.04,因此我必须手动启动该rc.local
服务,以便/etc/rc.local
可以在启动时执行命令。但是,我在启动服务时遇到了一些问题:
sunqingyao@sunqingyao-MacBookAir:~$ sudo service rc.local start
Job for rc-local.service failed because the control process exited with error code. See "systemctl status rc-local.service" and "journalctl -xe" for details.
以下是输出systemctl status rc-local.service
:
sunqingyao@sunqingyao-MacBookAir:~$ systemctl status rc-local.service
● rc-local.service - /etc/rc.local Compatibility
Loaded: loaded (/lib/systemd/system/rc-local.service; static; vendor preset: enabled)
Drop-In: /lib/systemd/system/rc-local.service.d
└─debian.conf
Active: failed (Result: exit-code) since Fri 2017-07-14 23:52:04 CST; 2min 13s ago
Process: 2420 ExecStart=/etc/rc.local start (code=exited, status=1/FAILURE)
Jul 14 23:52:04 sunqingyao-MacBookAir systemd[1]: Starting /etc/rc.local Compatibility...
Jul 14 23:52:04 sunqingyao-MacBookAir rc.local[2420]: Failed to connect to X Server.
Jul 14 23:52:04 sunqingyao-MacBookAir systemd[1]: rc-local.service: Control process exited, code=exited status=1
Jul 14 23:52:04 sunqingyao-MacBookAir systemd[1]: Failed to start /etc/rc.local Compatibility.
Jul 14 23:52:04 sunqingyao-MacBookAir systemd[1]: rc-local.service: Unit entered failed state.
Jul 14 23:52:04 sunqingyao-MacBookAir systemd[1]: rc-local.service: Failed with result 'exit-code'.
并且对于journalctl -xe
:
Jul 14 23:52:04 sunqingyao-MacBookAir sudo[2390]: sunqingyao : TTY=pts/0 ; PWD=/home/sunqingyao ; USER=root ; COMMAND=/usr/sbin/service rc.local start
Jul 14 23:52:04 sunqingyao-MacBookAir sudo[2390]: pam_unix(sudo:session): session opened for user root by (uid=0)
Jul 14 23:52:04 sunqingyao-MacBookAir systemd[1]: Starting /etc/rc.local Compatibility...
-- Subject: Unit rc-local.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit rc-local.service has begun starting up.
Jul 14 23:52:04 sunqingyao-MacBookAir rc.local[2420]: Failed to connect to X Server.
Jul 14 23:52:04 sunqingyao-MacBookAir systemd[1]: rc-local.service: Control process exited, code=exited status=1
Jul 14 23:52:04 sunqingyao-MacBookAir systemd[1]: Failed to start /etc/rc.local Compatibility.
-- Subject: Unit rc-local.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit rc-local.service has failed.
--
-- The result is failed.
Jul 14 23:52:04 sunqingyao-MacBookAir systemd[1]: rc-local.service: Unit entered failed state.
Jul 14 23:52:04 sunqingyao-MacBookAir systemd[1]: rc-local.service: Failed with result 'exit-code'.
Jul 14 23:52:04 sunqingyao-MacBookAir sudo[2390]: pam_unix(sudo:session): session closed for user root
答案1
谢谢@bodhi.zazen感谢他们在评论中对我的问题给予的善意指导!
回答我的问题:
该问题实际上是由 中的命令引起的rc.local
,其中包含以下行以启用自然滚动:
/usr/bin/synclient VertTwoFingerScroll=1
/usr/bin/synclient HorizTwoFingerScroll=1
/usr/bin/synclient VertScrollDelta=-150
/usr/bin/synclient HorizScrollDelta=-150
但是,执行此命令需要连接到所有图形应用程序都依赖的 X 服务器。但是,它rc.local
在 X 服务器启动之前执行,因此会出现Failed to connect to X Server
错误。
要修复此问题,只需从中删除该行rc.local
即可sudo service rc.local start
。
回答我的实际问题:
但删除该行并不能实现自然滚动。要实现这一点,您需要将配置放入 Xorg 配置文件中。
将以下几行添加到/usr/share/X11/xorg.conf.d/60-synaptics-options.conf
,请注意,您不必这样做chmod a+x
。
# Synaptic options
Section "InputClass"
Identifier "touchpad"
Driver "synaptics"
MatchIsTouchpad "on"
# Enable natural scrolling
Option "VertTwoFingerScroll" "1"
Option "HorizTwoFingerScroll" "1"
Option "VertScrollDelta" "-150"
Option "HorizScrollDelta" "-150"
EndSection
重新启动,自然滚动即可启用!