summaryrefslogtreecommitdiffstats
path: root/.local/bin/b-bar
blob: 864123835e226cd9062591f8e9279ef6ca1362a2 (plain) (blame)
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
#!/bin/sh
while true
do
    host="$(hostname)"
    vols="$(b-pavols)"
    load="$(cat /proc/loadavg | cut -d' ' -f1)"
    date="$(date +'%a, %d %b %Y %R %z')"

    bar="$vols | $load | $date"

    case $host in
        selene)
            sens="$(sensors -j w83795g-i2c-*-*)"
            cpu1="$(echo $sens | jq -r '.[].temp7.temp7_input')"
            cpu2="$(echo $sens | jq -r '.[].temp8.temp8_input')"
            # KGPE-D16 northbridge temperature
            nrbr="$(echo $sens | jq -r '.[].temp1.temp1_input')"
            bar="$cpu1 $cpu2 $nrbr | $bar"
            ;;
        adelita|anahita)
            [ "$host" = "anahita" ] && bdev="sbs_9_000b" || bdev="BAT0"
            b0="$(upower -i /org/freedesktop/UPower/devices/battery_$bdev)"
            batstat="$(echo "$b0" | awk '/state/{print $NF}')"
            if [ "$batstat" = "discharging" ]; then
                batstat='-'
            elif [ "$batstat" = "charging" ]; then
                batstat='+'
            fi
            batcap="$(echo "$b0" | awk '/percentage/ \
              {sub(/\%$/, "", $NF); \
               print $NF}')"
            battime="$(echo "$b0" | awk -F: '/time to (full|empty)/ \
              {sub(/^[ \t]+/, "", $NF); \
               sub(/\ hours?$/, "h", $NF); \
               print $NF}')"
            bat="${batcap}$batstat $battime"
            bar="$bat | $bar"
            ;;
        *)
            ;;
    esac

    printf "$bar\n"
    sleep 5
done