diff --git a/configure.ac b/configure.ac index 0b59c80fbb..903c61e474 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/examples/Makefile.am b/examples/Makefile.am index eeea87717f..a227f0ea7a 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -2,4 +2,5 @@ SUBDIRS= \ shell \ python \ ruby \ - C + C \ + dispatcher diff --git a/examples/dispatcher/70-wifi-wired-exclusive.sh b/examples/dispatcher/70-wifi-wired-exclusive.sh new file mode 100755 index 0000000000..501f159efc --- /dev/null +++ b/examples/dispatcher/70-wifi-wired-exclusive.sh @@ -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 + diff --git a/examples/dispatcher/Makefile.am b/examples/dispatcher/Makefile.am new file mode 100644 index 0000000000..0db71a0d4f --- /dev/null +++ b/examples/dispatcher/Makefile.am @@ -0,0 +1,3 @@ +EXTRA_DIST = \ + 70-wifi-wired-exclusive.sh +