~kris/dots

srice

ref: 2dc7c2f7e39f562e3603676ef50c2df0a4723c19 srice/.local/bin/statusbar/sb-internet -rwxr-xr-x 622 bytes
2dc7c2f7 — Kris Yotam update nvim plan9 theme, add hosts file, misc updates 6 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/sh

# Show internet connection status with 󰖩 (f05a9) icon

case $BLOCK_BUTTON in
	1) "$TERMINAL" -e nmtui; pkill -RTMIN+4 dwmblocks ;;
	3) notify-send "󰖩 Internet module" "\- Click to connect
- Shows connection quality percentage" ;;
	6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;;
esac

# Check wifi
if [ "$(cat /sys/class/net/w*/operstate 2>/dev/null)" = 'up' ]; then
	quality=$(awk '/^\s*w/ { print int($3 * 100 / 70) }' /proc/net/wireless)
	printf "󰖩 %s%%\n" "$quality"
# Check ethernet
elif [ "$(cat /sys/class/net/e*/operstate 2>/dev/null)" = 'up' ]; then
	printf "󰖩\n"
else
	printf "󰖩 --\n"
fi