Ubuntu – How to disable lock screen based on which WIFI network I’m connected to

lock-screenwireless

If I'm connected to my home wifi network, I do not want to have a lock screen when I resume from suspend or after X minutes of inactivity.

If I'm not connected to any wifi network or the name of the wifi network is different than my home network, I want the lock screen to be active.

How can I do that?

Best Answer

You can use this shell script. Check this to get the info of your WiFi.

#!/bin/sh

trusted_essid="trusted-wifi-name"

while :
do
  current_essid=$(iwgetid -r)
  if [ "$trusted_essid" = "$current_essid" ]
  then
    gsettings set org.gnome.desktop.lockdown disable-lock-screen true
    echo 1
  else
    gsettings set org.gnome.desktop.lockdown disable-lock-screen false
    echo 2
  fi
  sleep 60
done

Edit this file as root:

sudo gedit /etc/network/interfaces

add under wlan0 (or your Wifi interface, ls /sys/class/net | grep -o "wl[^\t]\+"):

post-up sh /path/to/wifi-smartlock.sh