We can catch the lid open/close events and could bind scripts to them by using acpid - Advanced Configuration and Power Interface event daemon.
- In attempt to check whether this suggestion works I've installed Ubuntu 17.10 on my DELL Vostro 3350. Then I've used
dconf-editor to disable the lid close action. But unfortunately I can't disable this action... So I just hope this could help you.
1. Catch the events. Execute one of the next commands, then close and open the lid: acpi_listen or netcat -U /var/run/acpid.socket. Here is an example output:
$ acpi_listen
button/lid LID close
button/lid LID open
2. Configure acpid to recognize the events triggered when the device mode is changed. Create the following files (don't forgot to use the actual events from the above step):
/etc/acpi/events/lid-close:
# /etc/acpi/events/lid-close
# This is called when the lid is closed
event=button/lid LID close
action=/etc/acpi/lid-actions.sh 1
/etc/acpi/events/lid-open:
# /etc/acpi/events/lid-open
# This is called when the lid is open
event=button/lid LID open
action=/etc/acpi/lid-actions.sh 0
3. Restart acpid so it can re-read the event filters, including the ones we just added:
sudo systemctl restart acpid.service
4. Create the script /etc/acpi/lid-actions.sh (and make it executable) that will suspend the laptop when the lid is close 1. I don't have idea what action could be useful when the lid is going to be open 0, so these lines are commented.
#!/bin/sh
if [ "${1}" -eq 1 ]; then systemctl suspend # Lid is close
#elif [ "${1}" -eq 0 ]; then # Lid is open
fi
References: