dotfiles/.local/bin/statusbar/sb-internet

31 lines
937 B
Plaintext
Raw Normal View History

2020-07-04 14:23:27 +02:00
#!/bin/sh
2023-10-12 22:52:40 +02:00
# Show wifi 📶 and percent strength or 📡 if none.
# Show 🌐 if connected to ethernet or ❎ if none.
# Show 🔒 if a vpn connection is active
2020-07-04 14:23:27 +02:00
case $BLOCK_BUTTON in
2023-10-12 22:52:40 +02:00
1) "$TERMINAL" -e nmtui; pkill -RTMIN+4 dwmblocks ;;
3) notify-send "🌐 Internet module" "\- Click to connect
❌: wifi disabled
2020-07-04 14:23:27 +02:00
📡: no wifi connection
📶: wifi connection with quality
❎: no ethernet
🌐: ethernet working
2023-10-12 22:52:40 +02:00
🔒: vpn is active
2020-07-04 14:23:27 +02:00
" ;;
2023-10-12 22:52:40 +02:00
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
2020-07-04 14:23:27 +02:00
esac
2023-10-12 22:52:40 +02:00
# Wifi
if [ "$(cat /sys/class/net/w*/operstate 2>/dev/null)" = 'up' ] ; then
wifiicon="$(awk '/^\s*w/ { print "" }' /proc/net/wireless)"
elif [ "$(cat /sys/class/net/w*/operstate 2>/dev/null)" = 'down' ] ; then
2023-10-15 10:08:06 +02:00
[ "$(cat /sys/class/net/w*/flags 2>/dev/null)" = '0x1003' ] && wifiicon=" " || wifiicon="❌ "
2023-10-12 22:52:40 +02:00
fi
2020-07-04 14:23:27 +02:00
2023-10-12 22:52:40 +02:00
# Ethernet
2023-10-15 10:08:06 +02:00
[ "$(cat /sys/class/net/e*/operstate 2>/dev/null)" = 'up' ] && ethericon=""
2020-07-04 14:23:27 +02:00
2023-10-12 22:52:40 +02:00
printf "%s%s%s\n" "$wifiicon" "$ethericon"