-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPowerBar.sh
executable file
·46 lines (34 loc) · 1.22 KB
/
PowerBar.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
# PowerStatus-dwm
# Author - HashTag-4512
# Date - 19/5/21
# A modular powerline statusbar for dwm
#powerline symbols
powerline_h="\ue0b2" #
powerline_s="\ue0b3" #
#main functions
datetime(){
date_time="$(date '+%d-%m-%Y %H:%M')" #date and time in dd-mm-yyy HH:MM format
printf "%s%s" "$(echo -e $powerline_s)" "$(echo -e " " $date_time)"
}
sound(){
vol="$(amixer get Master | sed -n 's/^.*\[\([0-9]\+\)%.*$/\1/p'| uniq)"
printf "%s%s" "$(echo -e $powerline_s)" "$(echo -e " " $vol'% ')"
}
battery(){
batc="$(cat /sys/class/power_supply/BAT0/capacity)" # contains a value from 0 to 100
bats="$(cat /sys/class/power_supply/BAT0/status)" # either "Charging" or "Discharging"
printf "%s%s %s" "$(echo -e $powerline_s)" "$(echo -e " " $batc'%')" "$(echo -e $bats)"
}
memory(){
ram="$(free -t | awk 'FNR == 2 {print ""$3/$2*100}')"
printf "%s%s" "$(echo -e $powerline_s)" "$(echo -e " " $ram'% ')"
}
process(){
cpu="$(ps -eo pcpu | awk 'BEGIN {sum=0.0f} {sum+=$1} END {print sum}')"
printf "%s%s" "$(echo -e $powerline_s)" "$(echo -e " " $cpu'%')"
}
#update every 30 seconds
while true; do
xsetroot -name "$(process) $(memory) $(battery) $(sound) $(datetime)"
sleep 30
done