mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-07-21 18:24:49 +00:00
examples: add dispatcher example for exclusive wired/wifi
This commit is contained in:
parent
ee22af6961
commit
aaa5d2f70f
|
@ -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
|
||||
|
|
|
@ -2,4 +2,5 @@ SUBDIRS= \
|
|||
shell \
|
||||
python \
|
||||
ruby \
|
||||
C
|
||||
C \
|
||||
dispatcher
|
||||
|
|
26
examples/dispatcher/70-wifi-wired-exclusive.sh
Executable file
26
examples/dispatcher/70-wifi-wired-exclusive.sh
Executable 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
|
||||
|
3
examples/dispatcher/Makefile.am
Normal file
3
examples/dispatcher/Makefile.am
Normal file
|
@ -0,0 +1,3 @@
|
|||
EXTRA_DIST = \
|
||||
70-wifi-wired-exclusive.sh
|
||||
|
Loading…
Reference in a new issue