summaryrefslogtreecommitdiff
path: root/scripts/status-linux
blob: 5fa4e13252d2cb8d581050ef5d8f072c25e69b51 (plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh

# Prints some status info to stdout. Includes:
#	- date and time
#	- battery
#	- wifi (requires nmcli)
#	- past notifications (requires notify)

# Usage: status [separator]

sep=${1:-" | "}

time=$(date +"%H:%M")
date=$(date +"%a %d %b")

if [ "$(pulsemixer --get-mute)" -eq 1 ]; then
	volume="Muted"
else
	volume="Vol $(pulsemixer --get-volume | awk '{print $1}')%"
fi

bat="/sys/class/power_supply/BAT0"
if [ -d $bat ]; then
	charge_status="$(cat $bat/status | awk '{print substr ($0, 0, 2)}')"
	battery="Bat $(cat $bat/capacity)% $charge_status"
else
	battery="No battery"
fi

# Thank you iwctl for saving us from this dreadful existence
network="$(iwctl station wlan0 show | grep 'Connected network' | \
	awk '{$1=$2=""; $0=$0; print}' | sed 's/^ .//')"
if [ "$(cat /sys/class/net/eth1/carrier 2>/dev/null)" = 1 ]; then
	if [ -z "$network" ]; then
		network="eth"
	else
		network="eth & $network"
	fi
fi

noticount=$(notify show | wc -l)

printf '%s' "$network$sep$volume$sep$battery$sep$date$sep$time"
[ "$noticount" = "1" ] && printf '%s' "$sep$(notify show)"
[ "$noticount" -gt "1" ] && printf '%s' "${sep}[$noticount]"
printf '\n'

Generated with cgit - Back to sebastiano.tronto.net