From 5c79830dfd41b95d1e982f71118c94a79af60422 Mon Sep 17 00:00:00 2001 From: kvj Date: Tue, 24 Oct 2023 12:51:24 +0200 Subject: [PATCH] Initial commit --- README.md | 0 dwm-bar | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 README.md create mode 100755 dwm-bar diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/dwm-bar b/dwm-bar new file mode 100755 index 0000000..9bedce6 --- /dev/null +++ b/dwm-bar @@ -0,0 +1,49 @@ +#!/bin/bash + +interval=0 + +pkg_updates() { + updates=$(emerge -pvu --newuse --deep --with-bdeps=y @world | grep Total | grep -o '[[:digit:]]*' | grep -m1 "") # gentoo + if [ "$updates" = 0 ]; then + printf "^c#efefef^ Fully Updated" + else + printf "^c#d4d5d5^ $updates"" updates" + fi +} + +weather() { + weather=$(curl -s wttr.in/Reda?format=1 | grep -o ".[0-9].*") + printf "^c#656565^  " + printf "^c#d4d5d5^$weather" + +} + +cpu() { + cpu_val=$(grep -o "^[^ ]*" /proc/loadavg) + + printf "^c#656565^  " + printf "^c#d4d5d5^$cpu_val" +} + +update_icon() { + printf "^c#656565^ 󰏗" +} + +mem() { + printf "^c#656565^ 󰍛 " + printf "^c#d4d5d5^ $(free -h | awk '/^Mem/ { print $3 }' | sed s/i//g)" +} + +clock() { + printf "^c#656565^  " + printf "^c#d4d5d5^ $(date '+%a, %I:%M %p') " +} + +while true; do + + [ $interval == 0 ] || [ $(($interval % 3600)) == 0 ] && updates=$(pkg_updates) + interval=$((interval + 1)) + + sleep 1 && xsetroot -name "$(update_icon) $updates $(weather) $(cpu) $(mem) $(clock)" +done +