Cannot start rc-local.service: Failed to connect to X Server
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!
Related videos on Youtube
nalzok
The best thing about being a statistician is that you get to play in everyone's backyard.
Updated on September 18, 2022Comments
-
nalzok over 1 year
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
-
derHugo almost 7 yearsAre you doing this local or over SSH?
-
Panther almost 7 yearsCan you describe what you are trying to do ? "Failed to connect to X Server" suggests you are trying to run a graphical application and in that case you likely want to either find a command line solutions (as X is not running at boot or with init scripts) or run the command at login.
-
nalzok almost 7 years@derHugo I'm doing this on my local machine.
-
derHugo almost 7 yearsDid you try to run
startx
before? -
nalzok almost 7 years@bodhi.zazen I'm trying to start the
rc.local
service on 16.04. Unfortunately,sudo systemctl enable rc-local.service
executed without error, but the service isn't started. So I triedsudo service rc.local start
. -
Panther almost 7 yearsYou have to describe what you are doing with rc.local for us to debug it. In general using or calling graphical apps will fail if you are not logged in as X is not running. So yes it will run once you log in, but not at boot. So probably better to re-write your scripts to not use X or run it at log in and not boot.
-
nalzok almost 7 years@derHugo I just ran
startx
, and then my screen turned black so I had to force a reboot :( -
nalzok almost 7 years@bodhi.zazen I have this in my
rc.local
:/usr/bin/synclient VertScrollDelta=-237
, which is used to enable natural scrolling. I suppose it has something to do with "graphical apps"? -
Panther almost 7 yearsYou should run that at login - askubuntu.com/questions/48321/… and not from rc.local, or you can write an xorg.conf
-
Panther almost 7 yearsSee also askubuntu.com/questions/290009/…
-
nalzok almost 7 years@bodhi.zazen Ahh thanks, the service started successfully after I commented out that line! However, I want the natural scrolling command executed every time I wake up from hibernation (see my previous question), and waking up does not mean logging in, so your links probably won't do the job :(
-
Panther almost 7 yearsPut your settings in /usr/share/X11/xorg.conf.d/60-synaptics-options.conf . See help.ubuntu.com/community/SynapticsTouchpad and wiki.archlinux.org/index.php/Touchpad_Synaptics
-
nalzok almost 7 years@bodhi.zazen After accidentally disabled my keyboard once, your method finally works! Please make these comments an answer, so that I can upvote and accept it!
-
Panther almost 7 yearsPost your config as the solution
-
nalzok almost 7 years@bodhi.zazen I'm done!
-
iamanigeeit about 4 yearsAccording to the /usr/share conf file, "DO NOT EDIT THIS FILE, your distribution will likely overwrite it when updating. Copy (and rename) this file into /etc/X11/xorg.conf.d first."
-