The problem you have is that the acpid events are handled outside of the users X process environment, so slock running in the event handler will have no connection to the user or the Xserver.
The way to workaround that is to have the acpid handler send some sort of signal to a screenlocker daemon process running within the users X environment.
A quick and dirty one knocked up in shellscript might look something like this:
/usr/local/bin/lid-locker:
Code:
#!/bin/sh
lockscreen()
{
xlock -mode blank
}
trap lockscreen SIGUSR1
trap exit SIGTERM SIGINT
echo lid-locker PID: $$
trap -p
while :
do
sleep 1d &
while ! wait
do
:
done
done
Have that started in the background from your xsession/xinitrc and then the acpid script just needs to
pkill --signal USR1 -x lid-locker
There might be more modern ways of doing something like this involving udev, or dbus, but I don't have much knowledge of those.
Hope that gives you some ideas.