aboutsummaryrefslogtreecommitdiff
path: root/dwm-status
blob: e95dad34d1df598625ff97a4f88c0278667a1590 (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
#!/bin/sh
while true; do
    datetime="$(date '+%d %a %H:%M')"

    # Volume
    if command -v pamixer >/dev/null 2>&1; then
        vol="$(pamixer --get-volume-human 2>/dev/null)"
    elif command -v amixer >/dev/null 2>&1; then
        vol="$(amixer get Master | awk -F'[][]' 'END{print $2}')"
    else
        vol="n/a"
    fi

    # Network on/off
    if ping -c1 -W1 8.8.8.8 >/dev/null 2>&1; then
        net="online"
    else
        net="offline"
    fi

    # CPU usage
    cpu="$(top -bn1 | awk '/^%Cpu/{print int($2+$4) "%"}')"

    # Memory
    mem="$(free -m | awk '/^Mem/{print $3 "M"}')"

    # VPN status
    if ip link show wg-vps >/dev/null 2>&1; then
        vpn="VPS on"
    else
        vpn="VPS off"
    fi

    xsetroot -name "$datetime | CPU $cpu | MEM $mem | VOL $vol | NET $net | $vpn   "
    sleep 5
done