mirror of
https://github.com/pigmonkey/spark.git
synced 2026-01-22 18:14:16 +00:00
do not enable wifi if an ethernet connection is still active
The interface status and type of the up/down state change that triggers the script is irrelevant.
This commit is contained in:
parent
86ccff0e37
commit
50ff2246ed
1 changed files with 6 additions and 10 deletions
|
|
@ -10,7 +10,6 @@ if [ -f "$skip_filename" ]; then
|
|||
exit 0
|
||||
fi
|
||||
|
||||
interface="$1"
|
||||
action="$2"
|
||||
|
||||
# Bail out if the action is not either up or down.
|
||||
|
|
@ -18,13 +17,10 @@ if [[ "$action" != "up" && "$action" != "down" ]]; then
|
|||
exit 0
|
||||
fi
|
||||
|
||||
iface_type=$(nmcli dev | grep "^$interface" | tr -s ' ' | cut -d' ' -f2)
|
||||
iface_state=$(nmcli dev | grep "^$interface" | tr -s ' ' | cut -d' ' -f3)
|
||||
|
||||
echo "$syslog_tag: Interface $interface = $iface_state ($iface_type) is $action"
|
||||
active_ethernet=$(nmcli conn show --active | tr -s ' ' | cut -d' ' -f3 | grep ethernet)
|
||||
|
||||
enable_wifi() {
|
||||
echo "$syslog_tag: Interface $interface ($iface_type) is down, enabling wifi."
|
||||
echo "$syslog_tag: No active ethernet connections, enabling wifi."
|
||||
nmcli radio wifi on
|
||||
}
|
||||
|
||||
|
|
@ -33,8 +29,8 @@ disable_wifi() {
|
|||
nmcli radio wifi off
|
||||
}
|
||||
|
||||
if [[ "$iface_type" = "ethernet" || -z "$iface_type" ]] && [ "$action" = "down" ]; then
|
||||
enable_wifi
|
||||
elif [ "$iface_type" = "ethernet" ] && [ "$action" = "up" ] && [ "$iface_state" = "connected" ]; then
|
||||
disable_wifi
|
||||
if [ -z "$active_ethernet" ]; then
|
||||
enable_wifi
|
||||
else
|
||||
disable_wifi
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue