aboutsummaryrefslogtreecommitdiff
path: root/Scripts/.local/scripts/set_bar
blob: c139115811aed0f9ec60c38d9f588adcc3c28338 (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
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
#!/bin/bash

delimiter=' | '

timedate() {
    echo $(date +'%a %F %R')
}

battery() {
    capacity=$(cat /sys/class/power_supply/BAT0/capacity) || break
    status=$(cat /sys/class/power_supply/BAT0/status)

    if [[ $status == "Charging" ]]
    then
        status=""
    else
        if [[ $capacity -ge 75 ]]
        then
            status=""
        elif [[ $capacity -ge 50 ]]
        then
            status=""
        elif [[ $capacity -ge 25 ]]
        then
            status=""
        elif [[ $capacity -ge 10 ]]
        then
            status=""
        else
            status=""
        fi
    fi
    echo "$status  $capacity%"
}

volume() {
    sinks="$(pactl list sinks)"
    vol="$(echo "$sinks" | grep '[0-9]\+%' | sed "s,.* \([0-9]\+\)%.*,\1,;1q")"

    if [[ $vol -gt 50 ]]
    then
        icon=""
    elif [[ $vol -gt 10 ]]
    then
        icon=""
    else
        icon=""
    fi

    echo "$icon $vol%"
}

ram() {
    echo $(vmstat -s -a -S M | grep 'used memory' | grep -Po "\d+")M
}

disk() {
    echo $(df | grep /dev/sda2 | awk '{print $5}')
}

connections() {
    internet=$(nmcli g | sed -n 2p | awk '{print $1}')
    if [[ $internet == "connected" ]]
    then
        echo "Connected"
    else
        echo "Not connected"
    fi
}

while true; do
    xsetroot -name "Meme level at $(disk) $delimiter $(ram) $delimiter $(volume) $delimiter $(battery) $delimiter $(connections) $delimiter $(timedate)"
    sleep 30s;
done