summaryrefslogtreecommitdiff
path: root/ar/.local/bin/ethwifi
blob: 1f76ace791f2e98b8bcff73d70f2b74e67531518 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/sh

check_ethernet() {
  interfaces=$(ip link | awk '/^[0-9]+: e/ {print substr($2, 1, length($2)-1)}')
  for iface in $interfaces; do
    ip link show "$iface" | grep -q 'state UP' && return 0
  done
  return 1
}

check_ethernet && nmcli radio wifi off && notify-send "📡 wifi: OFF" || {
  nmcli radio wifi on
  notify-send "📡 wifi: ON"
}

pkill -RTMIN+7 "${STATUSBAR:-dwmblocks}"