This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mydwmstatus
executable file
·87 lines (71 loc) · 1.51 KB
/
mydwmstatus
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
#!/bin/dash
#
#TODO
# put the info in the cache, for wifi, does not need to ask every time
usage() {
echo "Usage: $0 (help|kill)"
}
killitself() {
xsetroot -name "mydwmstatus is killed on $(date +'%H:%M:%S')" && pkill mydwmstatus
}
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))
status=$((100*( (total-prevtotal) - (idle-previdle) ) / (total-prevtotal) ))
echo " $status%"
}
mem(){
perc=`free | awk '/Mem/ {printf "%d\n", $3 * 100 / $2}'`
echo " $perc%"
if [ $perc -ge 90 ]; then
pkill firefox
fi
}
wifi() {
echo " $(getssid)"
}
battery0() {
case $(cat /sys/class/power_supply/BAT0/status) in
Full) status="?" ;;
Charging) status="+" ;;
Dischargin) status="-" ;;
esac
capacity=$(cat /sys/class/power_supply/BAT0/capacity)
if [ $capacity -ge 100 ];then
icon=""
elif [ $capacity -ge 75 ];then
icon=""
elif [ $capacity -ge 50 ];then
icon=""
elif [ $capacity -ge 25 ];then
icon=""
else
icon=""
fi
echo "$icon $capacity%$status"
}
myweather() {
weather text
}
mydate() {
icon=$(dayornight)
date +" %a %b.%d $icon %T"
}
istheretimer() {
pgrep timer > /dev/null && echo " "
}
main() {
while true; do
xsetroot -name "$(cpu) $(mem) $(battery0) | $(myweather) $(mydate) $(mymood)$(istheretimer)"
sleep 2
done
}
case $1 in
help|h) usage;;
kill|k) killitself;;
*) main;;
esac
# vim: filetype=sh