Tint2 executor to display current wifi connection data.
This project tries to use OpenBSD tools whenever possible and recently the project has implemented a feature which can connect to multiple networks provided they are listed in your /etc/hostname.if file. The following script lets the user know, with a single click, which of the possible networks is being used.
OpenBSD gains Wi-Fi "auto-join".
The script is still a little rough. One issue is that ifconfig line that is parsed for connection data can lead off with "nwid" or "ieee80211". The script currently uses "grep ieee80211". If you do not use the join command your can either replace ieee80211 with nwid in the script or add "join" to your /etc/hostname.if. Some spacing issues in the yad output lead to the addition of non-printable \t "tab".
~/Scripts/obsd_wifi.sh
Code:
#!/bin/sh
TEST="$(nc -dzw1 8.8.8.8 443 2>&1)"
if echo $TEST | grep '^Connect' >/dev/null ; then
# IFS; Inter Field Separator (see man ksh)
# to preserve newlines,save and set IFS to space only
OLD_IFS="${IFS}"
IFS=" "
# capture 'ifconfig' output once and reuse ....
IFCONFIG=$(ifconfig)
#echo ${IFCONFIG}
NWID="$(echo ${IFCONFIG} | grep ieee80211 | awk '{print $3}')"
CHAN="$(echo ${IFCONFIG} | grep ieee80211 | awk '{print $5}')"
BSSID="$(echo ${IFCONFIG} | grep ieee80211 | awk '{print $7}')"
SN="$(echo ${IFCONFIG} | grep ieee80211 | awk '{print $8}')"
IP="$(echo ${IFCONFIG} | grep inet | tail -n1 | awk '{print $2}')"
cat <<END
--------------------------------------
Current WiFi Connection
--------------------------------------
NWID:
$NWID
CHAN:
$CHAN
BSSID:
$BSSID
S/N:
$SN
IP:
$IP
END
else
cat <<END
----------------------------------
Currently Connection Test
nc google.com 443 is Down
----------------------------------
END
fi
~/Scripts/yad_wifi.sh
Code:
#!/bin/sh
yad --posx=-60 --posy=38 \
--text="$(sh /home/jsh/Scripts/obsd_wifi.sh 2>&1)" \
--undecorated --button=gtk-close:6
I added this as a second "button" in my tint2 panel configuration (P).
~/.config/tint2/tint2rc
Code:
#-------------------------------------
# Panel
panel_items = TSPPC
panel_size = 100% 38
-----
#-------------------------------------
# Button 1
button = new
button_icon = /usr/local/share/icons/gnome/32x32/status/weather-overcast.png
button_tooltip = "Yakima, WA Weather"
button_padding = 6 3 0
button_max_icon_size = 24
button_lclick_command = sh ~/scripts/yad_weather.sh
button_mclick_command =
button_rclick_command = sh ~/scripts/yad_weather.sh
# Button 2
button = new
button_icon = /usr/local/share/icons/gnome/32x32/devices/network-wireless.png
button_tooltip = "Wireless Connection"
button_padding = 6 3 0
button_max_icon_size = 24
button_lclick_command = sh ~/scripts/yad_wifi.sh
button_mclick_command =
button_rclick_command = sh ~/scripts/yad_wifi.sh
For those using Gnome, KDE4 or XFCE4, you can either make a obsd_wifi.desktop file ,described above, or use yad --notification to produce a sytemtray entry
yad Notification Options
yad Notification
This is the output positioned under the wireless icon in the tint2 panel