First, install acpi-support and xinput:

sudo apt install acpi-support xinput


Then find out the touchpad's device number:

xinput --list
 
⎡ Virtual core pointer                   id=2  [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer         id=4  [slave  pointer  (2)]
⎜   ↳ FSPPS/2 Sentelic FingerSensingPad  id=11 [slave  pointer  (2)]
⎣ Virtual core keyboard                  id=3  [master keyboard (2)]

As you can see, it's device 11. This may very well be different in your case though.

Now you'll have to find out if the lid switch works. (This is easier from another machine using SSH.)

With the lid opened, run:

cat /proc/acpi/button/lid/LID/state state:      open

Close the lid, and repeat:

cat /proc/acpi/button/lid/LID/state state:      closed


This argument has to be translated to an xinput parameter, which is simply 0 or 1 for enabling/disabling the touchpad.

grep -q closed /proc/acpi/button/lid/LID/state
echo $?
1

Close the lid, and repeat:

grep -q closed /proc/acpi/button/lid/LID/state
echo $?
0

So, with the lid opened, it generates 1, and with the lid closed, it generates 0.

In order to disable the touchpad, run the following command (in case it's device 11, of course):

xinput set-int-prop 11 "Device Enabled" 8 0

To re-enable it, run this:

xinput set-int-prop 11 "Device Enabled" 8 1

This can easily be automated using the output from the ACPI lid state:

grep -q closed /proc/acpi/button/lid/LID/state
xinput set-int-prop 11 "Device Enabled" 8 $?

With a closed lid, it will echo 0 to disable the touchpad, and when the lid opens, it will echo 1 to enable the touchpad.

All that's left to do now, is creating an ACPI event to automatically run these commands upon opening and closing the lid.

/etc/acpi/events/lm_lid
event=button/lid.*
action=/etc/acpi/lid.sh

Then, create the actual script. Keep in mind that the ACPI daemon runs as root, so in order for it to access the user's X session, you'll have to use some sorcery with .Xauthority files.

/etc/acpi/lid.sh
export XAUTHORITY=`ls -1 /home/*/.Xauthority | head -n 1`
export DISPLAY=":`ls -1 /tmp/.X11-unix/ | sed -e s/^X//g | head -n 1`"
 
grep -q closed /proc/acpi/button/lid/LID/state
xinput set-int-prop 11 "Device Enabled" 8 $?

Finally, make the script executable:

sudo chmod +x /etc/acpi/lid.sh

And finally restart the ACPI daemon:

sudo systemctl restart acpid.service


Now, using an SSH session, you can check whether the script works. Log in to the machine and try this:

export DISPLAY=:0.0
xinput --watch-props 11

When the lid is opened, you should see something like this:

Device 'FSPPS/2 Sentelic FingerSensingPad':
    Device Enabled (135):    1

When you close the lid, this should happen:

Property 'Device Enabled' changed.
    Device Enabled (135):    0