-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdwstatus
More file actions
executable file
·67 lines (59 loc) · 1.69 KB
/
dwstatus
File metadata and controls
executable file
·67 lines (59 loc) · 1.69 KB
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
#!/bin/bash
# DWM statusbar script
tgl(){
tgl="$(date +"%a, %d %b – %H:%M")"
echo -e "$tgl"
}
bat(){
perc="$(acpi -b | awk '{print +$4}')"
charge="$(acpi -b | grep "Charging")"
online="$(acpi -V | grep "on-line")"
full="$(acpi -b | grep 'Full')"
if [ -z "$charge" ] && [ -z "$perc" ]; then
echo -e "·BAT· no-bat"
elif [ -z "$charge" ] && [ "$perc" -le "20" ]; then
echo -e "·BAT· $perc% BATTERY LOW";
dunstify "Your battery is running low: $perc% remaining";
elif [ "$perc" -ge "85" ]; then
echo -e "·BAT· $perc%"
else
echo -e "·BAT· $perc%"
fi
}
vol(){
mute=`amixer get Master | grep off`
if [ -z $mute ]; then
vol=`amixer get Master | grep -m 1 -o '[0-9][0-9]*%'`
echo -e "\x02\uE05D\x01 $vol"
else
echo -e "\x02\uE05F\x01"
fi
}
mem(){
mem=`free -h | awk '/Mem:/ {printf("%s", $3)}'`
echo -e "·MEM· $mem"
}
cpu(){
read cpu a b c previdle rest < /proc/stat
prevtotal=$((a+b+c+previdle))
sleep 0.5
read cpu a b c idle rest < /proc/stat
total=$((a+b+c+idle))
cpu=$((100*( (total-prevtotal) - (idle-previdle) ) / (total-prevtotal) ))
echo -e "·CPU· $cpu%"
}
mpd(){
if mpc &> /dev/null && [[ $(mpc | wc -l) != 1 ]]; then
if [[ $(mpc | awk 'NR==2 {print $1}') == "[paused]" ]] ; then
echo -e "\x02\uE0FE\x01 $( mpc | head -1 )"
else
echo -e "\x02\uE0FD\x01 $( mpc | head -1 )"
fi
fi
}
while true ; do
# status=`echo -e "$(mpd) $(cpu) $(mem) $(vol) $(bat) $(tgl) "`
status=`echo -e "$(cpu) $(mem) $(bat) | $(tgl)"`
xsetroot -name "$status"
sleep 1s
done &