LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-12-2014, 08:24 PM   #1
binarybob0001
Member
 
Registered: Dec 2004
Distribution: Debian Wheezy
Posts: 444

Rep: Reputation: 30
synclient "Failed to connect to X Server"


I have a bluetooth mouse, and when I use it, I disable the touchpad on my laptop. If my mouse does not connect for some reason (it's happened before), I have no easy way to turn the touchpad back on.

I can enable the touchpad using a terminal in X with synclient TouchpadOff=0, but I can't get to a terminal in X with no mouse! If I switch to another terminnal (cntl+alt+f1), synclient fails with error message, "Failed to connect to X Server." I have tried DISPLAY=":0" with no effect. How can I get this to work? Is there a way to run a command on a terminal other than the one that I am logged into?

Thank you.
 
Old 07-13-2014, 02:49 AM   #2
binarybob0001
Member
 
Registered: Dec 2004
Distribution: Debian Wheezy
Posts: 444

Original Poster
Rep: Reputation: 30
I solved it! The solution is in the code block for those who do not care how I found the solution.

After some googling, I found that for synclient to work, it must use some environment variables set by X. I grabbed the variables using export -p > envars while logged in as a normal user in gnome-terminal. I switched to a regular non-X terminal and logged in as root. I copied the envars file to root's home and then sourced it. For those who do not know what sourcing is look here http://www.theunixschool.com/2012/04...cing-file.html. I ran synclient, and it worked, but I didn't want to import every environment variable from X into the console, so I went about narrowing down which variables were important. I referred to the ArchWiki article https://wiki.archlinux.org/index.php/Touchpad_Synaptics, and read the example code for "systems with multiple X sessions." They used both XAUTHORITY and DISPLAY. I removed all other environment variables, but those two, and tried the process again. It worked! Finally, I wrote a nice script called touchpad to take care of everything for me.
Code:
#!/bin/bash

declare -x DISPLAY=":0"
declare -x XAUTHORITY="/home/bob/.Xauthority"

if [ $1 = "on" ]
then
  synclient TouchpadOff=0
fi

if [ $1 = "off" ]
then
  synclient TouchpadOff=1
fi
Now, I can do everything I need to with ./touchpad on or ./touchpad off. Isn't life just wonderful. I hope this will help others in the future.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Centos Server Failed @ Bootup: Missing "/sbin/blkid" & "fsck" command not found beagle7 Linux - Newbie 4 08-24-2012 01:33 AM
"hub.c : connect-debounce failed, port 1 disabled " slk Linux - Software 3 11-10-2009 10:37 AM
How to fix "mysqladmin: connect to server at 'localhost' failed"? timiao Linux - Software 4 11-07-2009 10:16 PM
Trying webmin, getting "attempt to connect to 127.0.0.1:10000 (localhost) failed" jeffreybluml Linux - General 1 08-16-2007 11:16 AM
bind and named and "rndc: connect failed: connection refused" coffee9876 Linux - Networking 3 12-16-2003 10:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration