A modern way to do this is to use NetworkManager's dispatcher.d
Step 1 - Create a script that does what we want, in dispatcher.d:
sudo nano /etc/NetworkManager/dispatcher.d/99-disable-screen-lock
Step 2 - copy and past the following script:
#!/bin/bash -e
trusted_essid="YOUR-NETWORK-ESSID"
user="YOUR-USERNAME"
if [ "$2" = "up" ]; then
if [ "$CONNECTION_ID" = "$trusted_essid" ]; then
if [ sudo -u $user gsettings get org.gnome.desktop.screensaver lock-enabled
= "true" ]; then
touch /home/$user/.screen_lock_temporarily_disabled
sudo -u $user dbus-launch gsettings set org.gnome.desktop.screensaver lock-enabled 'false'
fi
fi
fi
if [ "$2" = "down" ]; then
if [ -f /home/$user/.screen_lock_temporarily_disabled ]; then
sudo -u $user dbus-launch gsettings set org.gnome.desktop.screensaver lock-enabled 'true'
rm /home/$user/.screen_lock_temporarily_disabled
fi
fi
exit 0
Step 3 - Set the script to executable
sudo chmod +x /etc/NetworkManager/dispatcher.d/99-disable-screen-lock
That's it. The script basically is run every time you connect or disconnect to any network. It then checks if the network you just connected to is the one you trust, and if the screenlock is currently enabled. If this is the case, then it disables the screen lock, and generates a temporary file to keep in mind that it was this script that disabled the screen lock. This is important because we don't want the script to be enabling the screen lock if we manualy (and intentionaly) disabled it for any reason.
Every time you disconnect from any network, the script checks for the temprary file and re-enables the screen lock
Hope you find it useful!