#!/bin/sh
# shellcheck disable=2034
coded_by='

In the name of Allah, the most Gracious, the most Merciful.

 ▓▓▓▓▓▓▓▓▓▓
░▓ Author ▓ Abdullah <https://abdullah.today>
░▓▓▓▓▓▓▓▓▓▓ YouTube <https://YouTube.com/AbdullahToday>
░░░░░░░░░░

░█░█░█▀█░█▀█░░░░░█▀█░█▀█░▀█▀░▀█▀░█▀▀░█░█
░█▄█░█▀▀░█▀█░░░░░█░█░█░█░░█░░░█░░█▀▀░░█░
░▀░▀░▀░░░▀░▀░▀▀▀░▀░▀░▀▀▀░░▀░░▀▀▀░▀░░░░▀░
'

# Get notified about connecting/disconnecting network with dunst, notify-send
# and wpa_supplicant. Keep this script somewhere in your $PATH and add this to
# your autostart (.xinitrc) file.

#
#for IF in /var/run/wpa_supplicant/* ; do
#  IF="${IF##*/}"
#    if [[ -d "/sys/class/net/${IF}/phy80211" ]] ; then
#      wpa_cli -p /var/run/wpa_supplicant -i "${IF}" -a #"${HOME}/.local/bin/wpa_notify" &
#    fi
#done


if [ "${2}" = 'DISCONNECTED' ] ; then
        notify-send -t 3000 'wpa_supplicant' "$1 disconnected!"
else
  ssid="$(wpa_cli -p "${WPA_CTRL_DIR}" -i "${1}" list_networks | awk "\$1 == ${WPA_ID} { print \$2 }")"
        notify-send -t 3000 'wpa_supplicant' "connected to $ssid"
fi
