This repository has been archived by the owner on Jun 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
statusbar.sh
executable file
·79 lines (63 loc) · 2.33 KB
/
statusbar.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
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
#! /bin/sh
# TODO
# battery
# parameters (temp, weather, optionals)
# notifications (mail)
# weather every hour
volume_state() {
volume_muted=$(pactl get-sink-mute @DEFAULT_SINK@ | awk '{ if ($2=="yes") { print "MUTED" } }')
if [ "$volume_muted" = 'MUTED' ]; then
volume_and_logo=" MUTED"
else
volume=$(pactl get-sink-volume @DEFAULT_SINK@ | awk 'NR==1{print $5}')
volume_and_logo=" VOL $volume"
fi
}
network_state() {
connection_type=$(ip route | grep default | awk 'NR==1{ print $5 }')
if [ "$connection_type" = wl* ]; then
essid=$(iw dev $connection_type info | grep ssid | awk '{ print $2 }')
info="WIFI $essid"
else
info="ETH $connection_type"
fi
network_up=$(wget -q --spider http://google.com ; echo $?)
if [ "$network_up" -eq 0 ]; then
network_and_logo=" $info"
else
network_and_logo=" $info"
fi
}
while true
do
# battery
battery_and_logo_full=" "
battery_and_logo_medium=" "
battery_and_logo_low=" "
# network
network_state
# cpu used
cpu_used=$(top -bn2 | grep '%Cpu' | tail -1 | grep -P '(....|...) id,'| awk '{print int (100-$8) "%"}')
cpu_and_logo=" CPU $cpu_used"
# disk used
disk_used=$(df -h / | awk 'NR==2{ print $5 }')
disk_and_logo=" DISK $disk_used"
# memory used
memory_used=$(free -g | awk 'NR==2{print int ($3/$2*100) "%"}')
memory_used_and_logo=" RAM $memory_used"
# volume
volume_state
# temperature
temp=$(cat /sys/devices/platform/coretemp.0/hwmon/hwmon1/temp1_input)
temp_calc="$(($temp / 1000))"
temp_and_logo=" TEMP $temp_calc"
# weather
# weather=$(curl -s https://wttr.in/Buenos_Aires?0Tq | awk 'NR==4{ print $2 "" }')
# weather=$(curl -s https://wttr.in/Buenos_Aires?0T | awk 'NR==4{ print $3 "" }')
# weather_and_logo=" $weather"
# date
date_and_time=$(date '+%A %d/%m/%Y %H:%M')
date_and_logo=" $date_and_time"
# xsetroot -name "$cpu_and_logo | $memory_used_and_logo | $temp_and_logo | $disk_and_logo | $volume_and_logo | $network_and_logo | $weather_and_logo | $date_and_logo "
xsetroot -name "$cpu_and_logo | $memory_used_and_logo | $temp_and_logo | $disk_and_logo | $volume_and_logo | $network_and_logo | $date_and_logo "
done