summaryrefslogtreecommitdiff
path: root/cfg/i3/kurobar.sh
blob: 70184600c9f0e95399504365ebfd9dae42ce2613 (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
#!/bin/bash

while true; do
	# --- volume percentage ---
	volume=$(pamixer --get-volume)

    # --- battery percentage ---
    if [ -d /sys/class/power_supply/BAT0 ]; then
        bat=$(cat /sys/class/power_supply/BAT0/capacity)
    else
        bat="N/A"
    fi

    # --- ram usage in gb ---
    mem_used=$(free -g | awk '/^Mem:/ {print $3}')
    mem_total=$(free -g | awk '/^Mem:/ {print $2}')

    # --- screen brightness (clean) ---
    # outputs just the % from brightnessctl -m
    bright=$(brightnessctl -m | awk -F, '{print $4}')

    # --- LAN ip ---
    # 192.168.x.x
    localip=$(hostname -i | grep -oE '192\.168\.[0-9]+\.[0-9]+')
    
    # --- public IP ---
    # attached to the fetchpubip service and the .config/i3/fetch_public_ip.sh script
    pubip=$(cat ~/.config/i3/public_ip.txt)

    # --- cpu usage ---
    #cpu_idle1=$(awk '/^cpu / {print $5}' /proc/stat)
    #cpu_total1=$(awk '/^cpu / {total=0; for(i=2;i<=NF;i++) total+=$i; print total}' /proc/stat)
    #cpu_idle2=$(awk '/^cpu / {print $5}' /proc/stat)
    #cpu_total2=$(awk '/^cpu / {total=0; for(i=2;i<=NF;i++) total+=$i; print total}' /proc/stat)
    #cpu=$((100 * ( (cpu_total2 - cpu_total1) - (cpu_idle2 - cpu_idle1) ) / (cpu_total2 - cpu_total1) ))

    # --- date/time ---
    dt=$(date '+%Y年%m月%d日 %H時%M分%S秒')

    # --- print bar line ---
    echo "vol.$volume% | bat.$bat% | bri.$bright | lan.$localip | pub.$pubip | $mem_used/$mem_total gb | $dt"

    sleep 0.01
done