diff options
| author | Eugene Triguba <hello@eugenetriguba.com> | 2025-11-27 20:26:21 -0500 |
|---|---|---|
| committer | Eugene Triguba <hello@eugenetriguba.com> | 2025-11-27 20:26:21 -0500 |
| commit | 028265c9a5a8b43c3aea00bb28c1aab7a2f700f4 (patch) | |
| tree | 9beb668f22781a0fdd0b0b0b7bd0f8fdbbe4c4dd | |
| parent | Adjust xinit and x resources (diff) | |
| download | dotfiles-028265c9a5a8b43c3aea00bb28c1aab7a2f700f4.zip | |
Update lemonbar
| -rwxr-xr-x | lemonbar-xft/.config/lemonbar-xft/bar.sh | 101 |
1 files changed, 93 insertions, 8 deletions
diff --git a/lemonbar-xft/.config/lemonbar-xft/bar.sh b/lemonbar-xft/.config/lemonbar-xft/bar.sh index d0e6eff..63fb4c1 100755 --- a/lemonbar-xft/.config/lemonbar-xft/bar.sh +++ b/lemonbar-xft/.config/lemonbar-xft/bar.sh @@ -1,14 +1,99 @@ #!/bin/sh -BG="#1c1c1c" -FG="#d0d0d0" -FONT="Hack:size=14:style=Regular" +RED="%{F#cd0000}" +YELLOW="%{F#cdcd00}" +RESET="%{F-}" + +net() { + ifconfig egress 2>/dev/null | awk '/inet / {print $2}' +} + +wifi() { + wifi_info=$(ifconfig iwm0 2>/dev/null | grep "ieee80211:") + if [ -n "$wifi_info" ]; then + ssid=$(echo "$wifi_info" | sed -n 's/.*join \(.*\) chan.*/\1/p' | tr -d '"') + signal=$(ifconfig iwm0 | awk '/ieee80211:/ {for(i=1;i<=NF;i++) if($i ~ /%/) print $i}' | head -1) + printf "%s %s %s" "$ssid" "$signal" "$(net)" + else + net + fi +} + +battery() { + apm_output=$(apm -alb) + ac_state=$(echo "$apm_output" | head -1) + percent=$(echo "$apm_output" | sed -n '2p') + charging=$(echo "$apm_output" | sed -n '4p') + + if [ "$ac_state" = "4" ]; then + echo "AC" + return + fi + + filled=$((percent / 10)) + bar="" + i=0 + while [ $i -lt 10 ]; do + if [ $i -lt $filled ]; then + if [ "$charging" = "1" ]; then + bar="${bar}+" + else + bar="${bar}#" + fi + else + bar="${bar}-" + fi + i=$((i + 1)) + done + + if [ "$percent" -lt 30 ] && [ "$charging" != "1" ]; then + bar="${RED}${bar}${RESET}" + elif [ "$percent" -lt 50 ] && [ "$charging" != "1" ]; then + bar="${YELLOW}${bar}${RESET}" + fi + + printf "%s%% %s" "$percent" "$bar" +} + +cpu() { + apm -Pv | awk '{gsub(/\(|\)/, ""); print $5, $6, $4}' +} + +memory() { + top -n | awk '/^Memory:/ { + split($3, r, "/"); + printf "Used:%s Free:%s Cached:%s", r[2], $6, $8 + }' +} + +temp() { + avg=$(sysctl hw.sensors | awk -F'=' '/temp/ { + gsub(/degC.*/, "", $2); + sum += $2; + count++ + } END { + printf "%.0f", sum/count + }') + + if [ "$avg" -ge 85 ]; then + printf "%s%d°C%s" "$RED" "$avg" "$RESET" + else + printf "%d°C" "$avg" + fi +} + +datetime() { + date '+%Y-%m-%d %H:%M' +} while true; do - DATE=$(date "+%Y-%m-%d %H:%M") - BAT=$(apm -l) - LOAD=$(sysctl -n vm.loadavg | awk '{print $1" "$2" "$3}') + printf "%%{l} %s | %s | %s | %s %%{r} %s | %s \n" \ + "$(battery)" \ + "$(temp)" \ + "$(cpu)" \ + "$(memory)" \ + "$(wifi)" \ + "$(datetime)" - echo " Load: $LOAD | Battery: $BAT% | $DATE " sleep 5 -done | lemonbar-xft -g x24 -B "$BG" -F "$FG" -f "$FONT" & +done |