Add river bar

This commit is contained in:
dmitz 2024-06-19 15:08:48 +03:00
parent 2ba5f9864c
commit e564abaa40
2 changed files with 60 additions and 0 deletions

13
.config/river/bar Executable file
View file

@ -0,0 +1,13 @@
#!/bin/sh
FIFO="$XDG_RUNTIME_DIR/sandbar"
[ -e "$FIFO" ] && rm -f "$FIFO"
mkfifo "$FIFO"
while cat "$FIFO"; do :; done | sandbar \
-hide-vacant-tags \
-font "monospace:size=10" \
-no-title \
-vertical-padding 3 \
-title-bg-color "#151515" \
-inactive-bg-color "#151515"

47
.config/river/status Executable file
View file

@ -0,0 +1,47 @@
#!/bin/sh
cpu() {
cpu=$(awk '{printf ($1 % 1000 == 0 ? "%.0f" : "%.2f") "°C", $1 / 1000}' /sys/class/thermal/thermal_zone0/temp)
}
memory() {
memory="$(free -h | sed -n "2s/\([^ ]* *\)\{2\}\([^ ]*\).*/\2/p")"
}
datetime() {
datetime="$(date '+%b %d %a, %I:%M %p')"
}
bat() {
read -r bat_status </sys/class/power_supply/BAT0/status
read -r bat_capacity </sys/class/power_supply/BAT0/capacity
if [[ "$bat_status" == "Charging" ]]; then
bat="🔌 $bat_capacity%"
else
bat="$bat_capacity%"
fi
}
display() {
echo "all status $memory | $cpu | $bat | $datetime" >"$FIFO"
}
printf "%s" "$$" > "$XDG_RUNTIME_DIR/status_pid"
FIFO="$XDG_RUNTIME_DIR/sandbar"
[ -e "$FIFO" ] || mkfifo "$FIFO"
sec=0
while true; do
sleep 1 &
wait && {
[ $((sec % 15)) -eq 0 ] && memory
[ $((sec % 15)) -eq 0 ] && cpu
[ $((sec % 60)) -eq 0 ] && bat
[ $((sec % 45)) -eq 0 ] && datetime
[ $((sec % 5)) -eq 0 ] && display
sec=$((sec + 1))
}
done