feat(suckless): bump to latest

This commit is contained in:
ange 2024-03-21 11:19:30 +01:00
parent f8ee677aa1
commit d0a9506b18
Signed by: ange
GPG key ID: 9E0C4157BB7BEB1D
52 changed files with 144 additions and 38 deletions

View file

@ -1,8 +1,9 @@
#!/bin/bash
# MODULES
function update_crypto() {
local c; c="$(crypto)" && crypto="$c"
local c
c="$(crypto 2> /dev/null)" && crypto="$c"
}
function update_cpu() {
@ -10,13 +11,14 @@ function update_cpu() {
}
function update_memory() {
memory=" $(free -h | awk '$1 == "Mem:" {print $3}')"
memory=" $(free -h | awk '/^Mem:/ {print $3}')"
}
function update_bat() {
local dir; dir="$(find /sys/class/power_supply/ -mindepth 1 -name 'BAT*' -print -quit)"
local cap; cap="$(cat "$dir/capacity")"
local dir cap
dir='/sys/class/power_supply/BAT0'
cap="$(cat "$dir/capacity")"
{ grep -qv Discharging "$dir/status" && bat=" $cap%"; } ||
{ [ "$cap" -gt 80 ] && bat=" $cap%"; } ||
{ [ "$cap" -gt 60 ] && bat=" $cap%"; } ||
@ -26,39 +28,39 @@ function update_bat() {
}
function update_sink_vol() {
local sink; sink="$(wpctl get-volume '@DEFAULT_AUDIO_SINK@')"
local vol;
local sink vol
if grep -q 'MUTED' <<< "$sink"; then
sink="$(wpctl get-volume '@DEFAULT_AUDIO_SINK@')"
if grep -q MUTED <<< "$sink"; then
sink_vol='🔇'
else
vol="$(awk '{print int($2 * 100)}' <<< "$sink")"
{ [ "$vol" -gt 67 ] && sink_vol=" $vol"; } ||
{ [ "$vol" -gt 33 ] && sink_vol=" $vol"; } ||
{ sink_vol=" $vol"; }
return
fi
vol="$(awk '{print int($2 * 100)}' <<< "$sink")"
{ [ "$vol" -gt 67 ] && sink_vol=" $vol"; } ||
{ [ "$vol" -gt 33 ] && sink_vol=" $vol"; } ||
{ sink_vol=" $vol"; }
}
function update_source_vol() {
local source; source="$(wpctl get-volume '@DEFAULT_AUDIO_SOURCE@')"
local vol;
local source vol
if grep -q 'MUTED' <<< "$source"; then
source_vol=""
else
vol="$(awk '{print int($2 * 100)}' <<< "$sink")"
source_vol=" $(awk '{print int($2 * 100)}' <<< "$source")"
source="$(wpctl get-volume '@DEFAULT_AUDIO_SOURCE@')"
if grep -q MUTED <<< "$source"; then
source_vol=''
return
fi
source_vol=" $(awk '{print int($2 * 100)}' <<< "$source")"
}
function update_wlp() {
local sig; sig="$(awk '$1 ~ "wlp" {print int($3)}' /proc/net/wireless)"
local ssid; ssid="$(nmcli device wifi show-password | sed -n 's/SSID:\s*//p')"
local sig ssid
[ -z "$ssid" ] && wlp='⚠' && return
[ -z "$sig" ] && sig=0
# https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/d9b06a95/src/libnmc-base/nm-client-utils.c#L628
sig="$(awk '/^wlp/ {print int($3)}' /proc/net/wireless)"
if [ -z "$sig" ]; then
wlp='⚠'
return
fi
ssid="$(nmcli device wifi show-password | sed -n 's/^SSID:\s*//p')"
{ [ "$sig" -gt 56 ] && wlp="▂▄▆█ $ssid"; } ||
{ [ "$sig" -gt 38 ] && wlp="▂▄▆_ $ssid"; } ||
{ [ "$sig" -gt 21 ] && wlp="▂▄__ $ssid"; } ||
@ -67,7 +69,7 @@ function update_wlp() {
}
function update_time() {
time="$(date "+%a %m/%d %R")"
time="$(date "+%a %m-%d %R")"
}
function display() {
@ -81,8 +83,8 @@ else
fi
# SIGNALING
# trap '<function>;display' 'RTMIN+n'
trap 'update_sink_vol;display' 'RTMIN'
# trap '<function>;display' 'RTMIN+n'
trap 'update_sink_vol;display' 'RTMIN'
# to update it from external commands
## kill -m "$(cat ~/.cache/pidofbar)"
# where m = 34 + n
@ -102,7 +104,6 @@ while true; do
update_time
display
}
sleep "$(awk "BEGIN {s=$(date '+%S.%N'); print 10 - s % 10}")" & wait
sec="$((sec + 10))"
done