feat: massive update

This commit is contained in:
ange 2024-01-04 10:07:50 +01:00
parent 23f34782a8
commit 82ebb9bc4b
No known key found for this signature in database
GPG key ID: 7A17056039D46BAB
45 changed files with 9166 additions and 1418 deletions

View file

@ -5,22 +5,24 @@ echo "$$" > "$HOME/.cache/pidofbar"
# MODULES
update_crypto() {
crypto="$(crypto)"
local c="$(crypto)"
[ -n c ] && crypto="$c |"
}
update_cpu() {
cpu=" $(grep -o "^[^ ]*" /proc/loadavg)"
cpu=" $(grep -o "^[^ ]*" /proc/loadavg) |"
}
update_memory() {
memory=" $(free -h | sed -n '2s/\([^ ]* *\)\{2\}\([^ ]*\).*/\2/p')"
memory=" $(free -h | sed -n '2s/\([^ ]* *\)\{2\}\([^ ]*\).*/\2/p') |"
}
update_bat() {
local dir; dir="$(echo /sys/class/power_supply/BAT*/ | sort -n | tail -n1)"
bat="$(grep -q Charging "$dir/status" && printf '' || printf '')"
bat="$bat $(cat "$dir/capacity")%"
bat="$bat $(cat "$dir/capacity")% |"
}
update_vol() {
@ -31,11 +33,12 @@ update_vol() {
else
vol=" $((10#$(tr -dc '0-9' <<< "$v")))"
fi
vol="$vol |"
}
update_wlp() {
local sig; sig="$(grep wlp /proc/net/wireless | awk '{print $3 * 100}')"
local ssid; ssid="$(nmcli -t -f name,device connection show --active | grep wlp | cut -d: -f1)"
local ssid; ssid="$(nmcli device wifi show-password | grep SSID | sed 's/SSID: //')"
[ -z "$ssid" ] && wlp='⚠' && return
[ -z "$sig" ] && sig=0
@ -46,19 +49,13 @@ update_wlp() {
{ [ "$sig" -gt 1650 ] && wlp="▂▄__ $ssid"; } ||
{ [ "$sig" -gt 275 ] && wlp="▂___ $ssid"; } ||
{ wlp="____ $ssid"; }
wlp="$wlp |"
}
update_time() {
time="$(date "+%a %m/%d %R")"
}
# For calcurse users, refer https://github.com/pystardust/automeet
#update_event () {
# event="$(calcurse -n | sed 1d | \
# sed -E "s_^ *\[(.*):(.*)\] ([^\t]*)\t?.*_[\1h \2m->\3]_")"
# [ "[]" = "$event" ] && event=""
#}
# modules that don't update on their own need to be run at the start for getting their initial value
while [ -z "$(wpctl get-volume '@DEFAULT_AUDIO_SINK@' 2> /dev/null)" ]; do
sleep 1
@ -70,7 +67,7 @@ reload_bar() {
}
display() {
"${DISPLAYCMD[@]}" "$crypto | $cpu | $memory | $vol | $wlp | $bat | $time"
"${DISPLAYCMD[@]}" "$crypto $cpu $memory $vol $wlp $bat $time"
}
# SIGNALING
@ -88,10 +85,12 @@ else
DISPLAYCMD=(xsetroot -name)
fi
# crypto & > /tmp
# sleep 5 && cat /tmp
sec=0
while true; do
[ "$((sec % 300))" = 0 ] && update_crypto
[ "$((sec % 5 ))" = 0 ] && {
[ "$((sec % 10))" = 0 ] && {
update_time
update_cpu
update_memory
@ -100,6 +99,6 @@ while true; do
display
}
sleep 1 & wait
sec="$((sec + 1))"
sleep "$(awk "BEGIN {s=$(date '+%S.%N'); print 10 - s % 10}")" & wait
sec="$((sec + 10))"
done