summaryrefslogtreecommitdiff
path: root/.config/eww/scripts/wireless
blob: 937aa28d4bccc4ebfdbb792c7f1e3593ecdd6f76 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/sh

export NOTIFY_SHORT=wireless
export NOTIFY_LONG=wireless

readonly CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/eww-wireless"

touch "$CACHE"

ssid="$(sudo wpa_cli status | sed -n 's/^ssid=//p')"
read -r prev_ssid <"$CACHE"

if [ "$ssid" != "$prev_ssid" ]
then
	echo "$ssid" >"$CACHE"
	if [ -z "$ssid" ]
	then
		notify 'Disconnected from the Network' \
			'You are not connected to any network'
	else
		notify 'Connected to Network' "You are now connected to the network ‘$ssid’"
	fi
fi

if [ -n "$ssid" ]
then
	jo icon=󰖩 ssid="$ssid"
else
	jo icon=󰖪 ssid='Not Connected'
fi