The laptop lid state can be retrieved by opening a console and entering
cat /proc/acpi/button/lid/LID/state