aboutsummaryrefslogtreecommitdiff
path: root/XMonad/baraction
blob: 0c9d12f13247a8ce2026514b4b2f02959411756b (plain)
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
#!/bin/zsh

clock() {
	datetime=$(date +"%d %b(%A) %H:%M")
	echo "%{B#6c71c4}%{F#f0f0f0}  $datetime  %{B-}%{F-}"
}

cpu_load() {
  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 "%{B#ff0077}%{F#FCFCFC}  CPU: $cpu%  %{B-}%{F-}"
}

cpu_temp() {
    CEL=$'\xc2\xb0C'
    temp=$( cat /sys/devices/virtual/thermal/thermal_zone0/temp )
    temp=`expr $temp / 1000`
    echo "%{B#135ef0}%{F#FCFCFC}  TEMP: "$temp$CEL"  %{B-}%{F-}"
}

mem_usage() {
	mem=$(free -m | grep Mem: | awk '{print$3 / $2 * 100}')
	echo "%{B#14eea0}%{F#232627}"
	printf "  MEM: %.0f%%  " $mem 
	echo "%{B-}%{F-}"
}

weather() {
	echo "wttr.in"
	# echo $(</tmp/weather_stat)
}

volume() {
	echo "volume"
}

s="  " # spacing between modules

while :; do
	echo "%{r}"$(weather)$s$(volume)$s$(cpu_temp)$s$(cpu_load)$s$(mem_usage)$s$(clock)
	sleep 3
done