examples: add dispatcher example for exclusive wired/wifi

This commit is contained in:
Dan Williams 2012-09-20 10:19:11 -05:00
parent ee22af6961
commit aaa5d2f70f
4 changed files with 32 additions and 1 deletions

View file

@ -839,6 +839,7 @@ examples/ruby/Makefile
examples/C/Makefile
examples/C/glib/Makefile
examples/C/qt/Makefile
examples/dispatcher/Makefile
vapi/Makefile
])
AC_OUTPUT

View file

@ -2,4 +2,5 @@ SUBDIRS= \
shell \
python \
ruby \
C
C \
dispatcher

View file

@ -0,0 +1,26 @@
#!/bin/bash
export LC_ALL=C
# This dispatcher script makes WiFi mutually exclusive with
# wired networking. When a wired interface is connected,
# WiFi will be set to airplane mode (rfkilled). When the wired
# interface is disconnected, WiFi will be turned back on.
enable_disable_wifi ()
{
result=$(nmcli dev | grep "802-3-ethernet" | grep -w "connected")
if [ -n "$result" ]; then
nmcli nm wifi off
else
nmcli nm wifi on
fi
}
if [ "$2" = "up" ]; then
enable_disable_wifi
fi
if [ "$2" = "down" ]; then
enable_disable_wifi
fi

View file

@ -0,0 +1,3 @@
EXTRA_DIST = \
70-wifi-wired-exclusive.sh