summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2014-04-25 09:54:05 -0500
committerDan Williams <dcbw@redhat.com>2014-04-28 17:07:02 -0500
commitb77b7510d6d0777325e48728084764fbb97b806e (patch)
treee884a8313f7ca73a811549a874447bf8621db645
parenta2eb4789ac2fe8a6389aabb83285bc667b86d941 (diff)
downloadNetworkManager-b77b7510d6d0777325e48728084764fbb97b806e.tar.gz
examples: update 70-wifi-wired-exclusive.sh (bgo #513488)
Tighten up with suggestions from Johannes Buchner and mention his contribution. Also fixes operation with current nmcli since it changed from "802-3-ethernet" -> "ethernet" and thus the script was broken. https://bugzilla.gnome.org/show_bug.cgi?id=513488
-rwxr-xr-xexamples/dispatcher/70-wifi-wired-exclusive.sh29
1 files changed, 9 insertions, 20 deletions
diff --git a/examples/dispatcher/70-wifi-wired-exclusive.sh b/examples/dispatcher/70-wifi-wired-exclusive.sh
index f295260b8d..676695f443 100755
--- a/examples/dispatcher/70-wifi-wired-exclusive.sh
+++ b/examples/dispatcher/70-wifi-wired-exclusive.sh
@@ -1,28 +1,17 @@
#!/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.
+#
+# Copyright 2012 Johannes Buchner <buchner.johannes@gmx.at>
+# Copyright 2012 - 2014 Red Hat, Inc.
+#
-enable_disable_wifi ()
-{
- result=$(nmcli dev | grep "802-3-ethernet" | grep -w "connected")
- if [ -n "$result" ]; then
- nmcli radio wifi off
- #with older nmcli, use nmcli nm wifi off
- else
- nmcli radio wifi on
- #with older nmcli, use nmcli nm wifi on
- fi
-}
-
-if [ "$2" = "up" ]; then
- enable_disable_wifi
-fi
-
-if [ "$2" = "down" ]; then
- enable_disable_wifi
+export LC_ALL=C
+if nmcli -t --fields type,state dev | grep -E "ethernet:connected" -q; then
+ nmcli radio wifi off
+else
+ nmcli radio wifi on
fi