[ltp] lenovo-lockbtn:cannot connect to X server
Jan Kundrát
linux-thinkpad@linux-thinkpad.org
Wed, 14 Nov 2007 01:42:11 +0100
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enig6A0402C3CC88C569C1C42C59
Content-Type: multipart/mixed;
boundary="------------090309080100070906070704"
This is a multi-part message in MIME format.
--------------090309080100070906070704
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Qiuye Wang wrote:
> and i got "cannot connect to X server" in /var/log/acpid.
> although if i direct run the script and it works.
Sure, that's because of X11 authentication works. I've attached the two
scripts that should give you a hint about how to fix your script.
Cheers,
-jkt
--=20
cd /local/pub && more beer > /dev/mouth
--------------090309080100070906070704
Content-Type: application/x-sh;
name="toggle-video.sh"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline;
filename="toggle-video.sh"
#!/bin/bash
# handler for Fn+F7
=2E /etc/acpi/utils.sh
umask 0077
STATE_DIR=3D/etc/acpi/state/video-toggle/
if [[ -f $STATE_DIR/state1 ]]; then
# go to internal-only
for x in /tmp/.X11-unix/*; do
displaynum=3D`echo $x | sed s#/tmp/.X11-unix/X##`
getXuser;
if [ x"$XAUTHORITY" !=3D x"" ]; then
export DISPLAY=3D":$displaynum"
su $user -c "$aticonfig --effective=3Dnow --enable-monitor=3Dlvds && x=
randr -s 1400x1050"
su $user -c "xgamma -rgamma 1.15 -ggamma 1.05 -bgamma 1"
#su $user -c "xgamma -rgamma 1.250 -ggamma 1.100 -bgamma 0.750"
fi
done
rm $STATE_DIR/state* 2>/dev/null
touch $STATE_DIR/state2
#elif [[ -f $STATE_DIR/state2 ]]; then
else
# go to home LCD
for x in /tmp/.X11-unix/*; do
displaynum=3D`echo $x | sed s#/tmp/.X11-unix/X##`
getXuser;
if [ x"$XAUTHORITY" !=3D x"" ]; then
export DISPLAY=3D":$displaynum"
su $user -c "$aticonfig --effective=3Dnow --enable-monitor=3Dcrt1 && x=
randr -s 1680x1050"
#su $user -c "xgamma -rgamma 1.090 -ggamma 0.890 -bgamma 0.800"
su $user -c "xgamma -rgamma 1.035 -ggamma 0.895 -bgamma 0.800"
fi
done
rm $STATE_DIR/state*
#touch $STATE_DIR/state3 2>/dev/null
touch $STATE_DIR/state1 2>/dev/null
#else
# # both
# for x in /tmp/.X11-unix/*; do
# displaynum=3D`echo $x | sed s#/tmp/.X11-unix/X##`
# getXuser;
# if [ x"$XAUTHORITY" !=3D x"" ]; then
# export DISPLAY=3D":$displaynum"
# su $user -c "$aticonfig --enable-monitor=3Dcrt1,lvds --effective=3Dno=
w && xrandr -s 3080x1050"
# #su $user -c "xgamma -rgamma 1.090 -ggamma 0.890 -bgamma 0.800"
# su $user -c "xgamma -rgamma 1.035 -ggamma 0.895 -bgamma 0.800"
# fi
# done
# rm $STATE_DIR/state*
# touch $STATE_DIR/state1 2>/dev/null
fi
--------------090309080100070906070704
Content-Type: application/x-sh;
name="utils.sh"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline;
filename="utils.sh"
aticonfig=3D'/opt/bin/aticonfig'
getXuser() {
user=3D`finger| grep -m1 ":$displaynum " | awk '{print $1}'`
if [ x"$user" =3D x"" ]; then
user=3D`finger| grep -m1 ":$displaynum" | awk '{print $1}=
'`
fi
if [ x"$user" !=3D x"" ]; then
userhome=3D`getent passwd $user | cut -d: -f6`
export XAUTHORITY=3D$userhome/.Xauthority
else
export XAUTHORITY=3D""
fi
}
--------------090309080100070906070704--
--------------enig6A0402C3CC88C569C1C42C59
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHOkRjamXfqERyJRcRAo6tAKCVnnUeSxjzh2VihfUXUTCwa/UENACggMI6
Gw105CtbTJmEq70Ja4g2nDw=
=YlT8
-----END PGP SIGNATURE-----
--------------enig6A0402C3CC88C569C1C42C59--