0

Since I'm using 16.04, I have to manually start the rc.local service, so that commands in /etc/rc.local can be executed on start up. However, I'm having some trouble starting the service:

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.

Here is the output of 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'.

and for 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
nalzok
  • 257

1 Answers1

2

Thanks @bodhi.zazen for their kind instruction in the comments to my question!

To answer my question:

The problem is actually caused by the commands in rc.local, which contains the following line to enable natural scrolling:

/usr/bin/synclient VertTwoFingerScroll=1
/usr/bin/synclient HorizTwoFingerScroll=1
/usr/bin/synclient VertScrollDelta=-150
/usr/bin/synclient HorizScrollDelta=-150

However, executing this command requires connecting to the X Server, which all graphical applications depend on. However, rc.local is executed before X server is started, and thus the Failed to connect to X Server error.

To fix this, simply remove that line from rc.local, and sudo service rc.local start would work fine.

To answer my actual question:

Removing that line does not enable natural scrolling, though. In order to do this, you need to put the configuration in a Xorg configuration file.

Add the following lines to /usr/share/X11/xorg.conf.d/60-synaptics-options.conf, note that you don't have to 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

reboot, and natural scrolling is enabled!

nalzok
  • 257