mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 21:38:06 +02:00
examples: add dispatcher example for exclusive wired/wifi
This commit is contained in:
parent
ee22af6961
commit
aaa5d2f70f
4 changed files with 32 additions and 1 deletions
|
|
@ -839,6 +839,7 @@ examples/ruby/Makefile
|
||||||
examples/C/Makefile
|
examples/C/Makefile
|
||||||
examples/C/glib/Makefile
|
examples/C/glib/Makefile
|
||||||
examples/C/qt/Makefile
|
examples/C/qt/Makefile
|
||||||
|
examples/dispatcher/Makefile
|
||||||
vapi/Makefile
|
vapi/Makefile
|
||||||
])
|
])
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
|
|
||||||
|
|
@ -2,4 +2,5 @@ SUBDIRS= \
|
||||||
shell \
|
shell \
|
||||||
python \
|
python \
|
||||||
ruby \
|
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…
Add table
Reference in a new issue