[ltp] lenovo-lockbtn:cannot connect to X server

Jeffrey Taylor linux-thinkpad@linux-thinkpad.org
Tue, 13 Nov 2007 12:24:56 -0600


Quoting Qiuye Wang <qiuyew@gmail.com>:
> Hello list,
> 
> i want to use the Fn+F2 to lock my screen, and because the default
> lockbtn.sh in /etc/acpi does nothing (which uses acpi_fakekey
> $KEY_COFFEE), i put the following in lockbtn.sh:
> #!/bin/sh
> kdesktop_lock --forcelock
> 
> and i got "cannot connect to X server" in /var/log/acpid.
> although if i direct run the script and it works.
> 
> so, could anyone please help?

Are you running the script by hand as a normal user?  Try it as root.  It may
give the same error message.  If so, try "xhost +localhost" as the normal
user.  IIRC, the Fn scripts run as root.

Normally, another user, including root, cannot use your X server session.  The
above command gives any user on your computer permission to use your X server
session.  If the above works, add it to your login scripts (.bashrc, .profile,
etc. depending on shell).

HTH,
  Jeffrey