I managed to figure out a workaround, though I imagine there's a better solution out there. I looked at what was happening when my lid was closed and opened in /etc/acpi/lid.sh
and found that xscreensaver was being called upon automatically. Not sure if different laptops have different settings and whatnot - I really don't know too much about this stuff.
In any case, I tried to make it simply obey its config file and not lock, but couldn't figure it out, so I ended up simply deleting the lines that involved xscreensaver. Now everything works great: no locking, and if the lid is closed passed the amount of time which you have set for xscreensaver to start, it'll start normally (and not lock).
I'm still not sure why xscreensaver is set up to be called automatically when the lid is closed or why it ignores its settings and locks when the lid is opened. I also don't get why with my older laptop this only happens sporadically (sometimes it locks every time, sometimes not at all), despite having the same lid.sh file.
I should also note that I'm using Ubuntu 12.04 with Unity, though I don't think that'll make any difference.
I scoured the 'net for solutions that respected the Ubuntu/GNOME settings but ultimately this was the only thing that worked for me:
sudo vim /etc/UPower/UPower.conf
# <snip> ...
ignoreLid=true
# <snip> ...
On systemd
operating systems you can issue the command sudo service upower restart
to have the new config take effect. Otherwise, you need to reboot.
Best Answer
This guide is what helped solve the issue for me: http://tipsonubuntu.com/2018/04/28/change-lid-close-action-ubuntu-18-04-lts/
Basically, open your preferences using
sudo gedit /etc/systemd/logind.conf
and change the line starting withHandleLidSwitch
toHandleLidSwitch=ignore