I placed it in .xinitrc which I think was wrong to do.
#!/bin/bash
LOCKER=$(slock)
if [ $LOCKER -eq 1 ]; then
exec xinput --set-prop 8 "Device Enabled" 0
else
exec xinput --set-prop 8 "Device Enabled" 1
fi
where should I placed it and is it written correctly. thanks in advance