forked from jdpedersen1/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bar.sh
executable file
·96 lines (82 loc) · 2.55 KB
/
bar.sh
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
##############################
# VOLUME
##############################
vol() {
vol="$(amixer -D pulse get Master | awk -F'[][]' 'END{ print $4":"$2 }')"
echo -e " $vol"
}
##############################
# WORKSPACES #
##############################
workspaces() {
while true; do
if read line < $PANEL_FIFO; then
wm_status=""
IFS=':' read -a array <<< "$line"
for element in "${array[@]}"; do
if [[ $element =~ ^D ]]; then
wm_status="$wm_status ^fg(white)${element:1}"
elif [[ $element =~ ^d ]]; then
wm_status="$wm_status ^ca(1, bspc use ${element:1})^fg(darkgray)${element:1}^ca()"
elif [[ $element =~ ^E ]]; then
wm_status="$wm_status ^ca(1, bspc use ${element:1})^fg(#6b6b6b)${element:1}^ca()"
elif [[ $element =~ ^L ]]; then
wm_status="$wm_status • ^ca(1, bspc cycle_layout)^fg(white)${element:1}^ca()"
fi
done
echo $wm_status
fi
done
}
##############################
# UPGRADES
##############################
upgrades() {
cupd=$(checkupdates | wc -l)
printf "$cupd \n"
}
##############################
# KERNEL
##############################
kernel() {
kernel="$(uname -r)"
echo " $kernel"
}
## BATTERY
bat() {
batstat="$(cat /sys/class/power_supply/BAT0/status)"
battery="$(cat /sys/class/power_supply/BAT0/capacity)"
if [ $batstat = 'Charging' ]; then
batstat="^"
elif [ $batstat = 'Discharging' ]; then
batstat="v"
elif [[ $battery -ge 5 ]] && [[ $battery -le 19 ]]; then
batstat=""
elif [[ $battery -ge 20 ]] && [[ $battery -le 39 ]]; then
batstat=""
elif [[ $battery -ge 40 ]] && [[ $battery -le 59 ]]; then
batstat=""
elif [[ $battery -ge 60 ]] && [[ $battery -le 79 ]]; then
batstat=""
elif [[ $battery -ge 80 ]] && [[ $battery -le 95 ]]; then
batstat=""
elif [[ $battery -ge 96 ]] && [[ $battery -le 100 ]]; then
batstat=""
fi
echo "$batstat $battery %"
}
network() {
wifi="$(ip a | grep wlo1 | grep inet | wc -l)"
if [ $wifi = 1 ]; then
echo "ok"
else
echo "ng"
fi
}
SLEEP_SEC=2
#loops forever outputting a line every SLEEP_SEC secs
while :; do
echo " ^i(/home/jake/.xmonad/xpm/xmonad_xpm_pac_20.xpm) = $(upgrades) | kernel = $(kernel) | vol = $(vol) | Batt = $(bat) | wifi = $(network) "
sleep $SLEEP_SEC
done