4

I'm running Ubuntu 14.04 and it would be helpful if I can do this. My phone can do it, my laptop should be able to!

1 Answers1

2

Based on the answer given in the link in Glutanimate's comment, I've written this script that partially does the job.

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

SSID="myworkssid"
ESSID=`nm-tool |grep --only-matching '*[^ ][^:]*' |sed 's/^*//'`

if [ "$INTERFACE" = "wlan0" ]
  then
   if [ "$SSID" = "$ESSID" ] &&  [ "$ACTION" = "up" ]
    then 
    #Mute
        amixer -c 0 set Master playback 0% mute
   else
     #unmute
        amixer -c 0 set Master playback 100% unmute
   fi
fi

It has to be copied to /etc/NetworkManager/dispatcher.d/ and it has to be executable and owned by root, based on this link.

However, this script only partially does the job because the unmute command doesn't work. If someone can figure out a way to unmute, I'd be grateful.