-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdwmstatus
executable file
·78 lines (69 loc) · 2.4 KB
/
dwmstatus
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
#!/bin/sh
laptop=0
date_and_time() {
DAT="$(date '+%Y.%m.%d %H:%M')"
echo -n "$DAT"
}
updates() {
UPD="$(checkupdates+aur | wc -l)"
echo -n "$UPD"
}
memory_percentage() {
MEM_TOTAL="$(head -n1 /proc/meminfo | sed 's/MemTotal:\s*//;s/\s*kB//')"
MEM_FREE="$(grep -i -m1 free /proc/meminfo | sed 's/MemFree:\s*//;s/\s*kB//')"
MEM_BUFFER="$(grep -i -m1 buffers /proc/meminfo | sed 's/Buffers:\s*//;s/\s*kB//')"
MEM_CACHE="$(grep -i -m1 cached /proc/meminfo | sed 's/Cached:\s*//;s/\s*kB//')"
MEM_USED=$(echo "$MEM_TOTAL-$MEM_FREE-$MEM_BUFFER-$MEM_CACHE" | bc)
MEM_PERCENTAGE=$(echo "scale=1; 100*$MEM_USED/$MEM_TOTAL" | bc)
MEM_PERCENTAGE=$(echo "$MEM_PERCENTAGE" | bc)
MEM_PERCENTAGE=$(printf "%.1f\n" $MEM_PERCENTAGE)
echo -n "$MEM_PERCENTAGE%"
}
cpu_percentage() {
set -- $(mpstat -P 0 | sed '$!d;s/\S*\s\SM//')
#CPU=$2
CPU=$(printf "%.1f\n" $2)
echo -n "$CPU%"
}
mpc_current() {
current=$(mpc current)
echo -n "$current"
}
local_ip() {
set -- $(ip a | grep inet | grep -v 127.0.0.1 | grep -v inet6)
LOCAL_IP=$(echo $2 | sed 's/\/\S*//')
echo -n "$LOCAL_IP"
}
battery() {
CHARGE_OR_DISCHARGE="$(acpi | sed 's/\S*\s\S*\s//;s/,.*//')"
BATTERY_PERCENTAGE="$(acpi | sed 's/\S*\s\S*\s\S*\s//;s/\%.*//')"
BATTERY_DIVFIVE=$(echo "scale=1; $BATTERY_PERCENTAGE/5" | bc)
BATTERY_DIVFIVE_INV=$(echo "scale=1; 20-$BATTERY_DIVFIVE" | bc)
THREEPLUS=$(echo "scale=1; 3+$BATTERY_DIVFIVE" | bc)
TWENTYMINUS=$(echo "scale=1; 20-$BATTERY_DIVFIVE_INV" | bc)
#echo -n "^r0,7,2,4^^r2,4,22,10^^c#08090D^^r3,5,20,8^^c#939394^^r$THREEPLUS,5,$TWENTYMINUS,8^^d^^f24^ $BATTERY_PERCENTAGE%"
if [[ "$CHARGE_OR_DISCHARGE" == "Charging" ]]; then
echo -n "$BATTERY_PERCENTAGE%"
else
echo -n "$BATTERY_PERCENTAGE%"
fi
}
volume() {
VOL="$(amixer -M sget Master | tail +5 | sed 's/.*Playback\s//;s/..\s\[//;s/\%.*//')"
if amixer get Master | sed 5q | grep -q '\[on\]'; then
echo -n "$VOL%"
else
echo -n "$VOL%"
fi
}
if [[ $laptop -eq 1 ]]; then
while true; do
xsetroot -name " $(local_ip) | $(cpu_percentage) | $(memory_percentage) | $(volume) | $(battery) | $(updates &) | $(date_and_time) "
sleep 30
done
else
while true; do
xsetroot -name " $(local_ip) | $(cpu_percentage) | $(memory_percentage) | $(updates &) | $(date_and_time) "
sleep 30
done
fi