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!
-
I've idea for a script that could do that , but right now don't have time to write.– Sergiy KolodyazhnyyMar 10, 2015 at 16:58
-
There used to be a simple app called Cuttlefish that could do this, but it looks like it has been abandoned. Sorry :/. This Q&A might be a good starting point for devising a script as an alternative.– GlutanimateMar 10, 2015 at 19:59
Add a comment
|
1 Answer
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.
-
Option 1:
amixer set Master toggle
. Option 2:amixer sset Master unmute; amixer sset PCM unmute; amixer sset "Master Mono" unmute
. Option 3: usepactl
instead.pactl set-sink-mute 0 1; pactl set-sink-mute 0 0
. Sources: askubuntu.com/questions/258580/…; techytalk.info/…; arvydas.co.uk/2012/08/… Mar 11, 2015 at 15:28 -
I've tried quite a few options with amixer. None of them work. The terminal output is as expected, but the sound output remains muted. I'll try pactl and get back to you! Mar 12, 2015 at 7:08
-
I hear that problem with amixer is it has many channels and no single unmute (at least none I know of!). :-) Thus I offered toggle. And pactl, in case it doesn't toggle. ;-) Hope this will help. If it will, feel free to incorporate it in your reply. I've upvoted it already. Mar 12, 2015 at 19:21