3

I want to write a bash script that will put off dropbox automatic synchronization if i'm connected to particular wifi ssid. How can i catch this event: for example i'm working at home and sync is on, if i'm at another place (cafe, work, etc) auto sync is off.

Also I want to do some other task depending on wifi ssid.

0

1 Answer 1

6

You can write a dispatcher script stored in /etc/NetworkManager/dispatcher.d/ with content for example (not tested):

#!/bin/bash
# nm sets this values
INTERFACE=$1
ACTION=$2

SSID="yourssid"
ESSID=`iwconfig $INTERFACE | grep ESSID | cut -d":" -f2 | sed 's/^[^"]*"\|"[^"]*$//g'`

if [ "$INTERFACE" == "wlan0" ]; then
  if [ "$SSID" == "$ESSID" ] && [ "$ACTION" == "up" ]; then
    #activate dropbox sync
  else
    #deactivate dropbox sync
  fi
fi
1
  • Why dispatcher and not if-up.d?
    – Menasheh
    Jan 3, 2017 at 19:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .