diff options
author | Xiao Pan <gky44px1999@gmail.com> | 2023-02-04 14:38:26 -0800 |
---|---|---|
committer | Xiao Pan <gky44px1999@gmail.com> | 2023-02-04 14:38:26 -0800 |
commit | c3a302254693cec0ecd5fe173b3c9eb2145ea597 (patch) | |
tree | 1f495a5d672e3d8d52ede9645f4cfac30a997dfb /etc/NetworkManager | |
parent | 93993544049196d579173558ef55cbedcd12eb73 (diff) |
use arch wiki example to fix issue of need nmcli wifi on when unplug ethernet cable after poweroff
Diffstat (limited to 'etc/NetworkManager')
-rwxr-xr-x | etc/NetworkManager/dispatcher.d/70-wifi-wired-exclusive | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/etc/NetworkManager/dispatcher.d/70-wifi-wired-exclusive b/etc/NetworkManager/dispatcher.d/70-wifi-wired-exclusive index 79e18eb2..a0f0c4c8 100755 --- a/etc/NetworkManager/dispatcher.d/70-wifi-wired-exclusive +++ b/etc/NetworkManager/dispatcher.d/70-wifi-wired-exclusive @@ -1,17 +1,16 @@ #!/bin/sh -# code modified from: -# `man nmcli-examples` and Copyright 2012 Johannes Buchner <buchner.johannes@gmx.at> Copyright 2012 - 2014 Red Hat, Inc. +# https://wiki.archlinux.org/title/NetworkManager#Use_dispatcher_to_automatically_toggle_wireless_depending_on_LAN_cable_being_plugged_in -enable_disable_wifi () -{ - if nmcli -t --fields type,state device | grep -q 'ethernet:connected'; then - nmcli radio wifi off - else - nmcli radio wifi on - fi -} - -case "$2" in - up|down) enable_disable_wifi;; -esac +if [ "$1" = "enp3s0" ]; then + case "$2" in + up) + nmcli radio wifi off + ;; + down) + nmcli radio wifi on + ;; + esac +elif [ "$(nmcli -g GENERAL.STATE device show enp3s0)" = "20 (unavailable)" ]; then + nmcli radio wifi on +fi |