From e139a3e20c7572ee71fedc627fe3fd67ed031217 Mon Sep 17 00:00:00 2001 From: Prateek Shukla Date: Sun, 22 Dec 2024 13:19:37 +0530 Subject: [PATCH 1/2] Update bar.sh Solved the sddm crash problem by changing script to bash Changed some of the glyphs (some of them were non scalable so looked small on laptops) Slightly changed the pkg_updates to work on arch linux only (as I don't know how to do it on void linux) --- scripts/bar.sh | 57 +++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/scripts/bar.sh b/scripts/bar.sh index 7f98d652..24de48e5 100755 --- a/scripts/bar.sh +++ b/scripts/bar.sh @@ -1,4 +1,4 @@ -#!/bin/dash +#!/bin/bash # ^c$var^ = fg color # ^b$var^ = bg color @@ -8,33 +8,35 @@ interval=0 # load colors . ~/.config/chadwm/scripts/bar_themes/onedark -cpu() { - cpu_val=$(grep -o "^[^ ]*" /proc/loadavg) - - printf "^c$black^ ^b$green^ CPU" - printf "^c$white^ ^b$grey^ $cpu_val" -} - +# Update checking function (Arch Linux) pkg_updates() { - #updates=$({ timeout 20 doas xbps-install -un 2>/dev/null || true; } | wc -l) # void - updates=$({ timeout 20 checkupdates 2>/dev/null || true; } | wc -l) # arch - # updates=$({ timeout 20 aptitude search '~U' 2>/dev/null || true; } | wc -l) # apt (ubuntu, debian etc) - - if [ -z "$updates" ]; then + updates=$(checkupdates 2>/dev/null | wc -l) + if [[ -z "$updates" ]]; then printf " ^c$green^  Fully Updated" else - printf " ^c$green^  $updates"" updates" + printf " ^c$green^  $updates updates" fi } battery() { - get_capacity="$(cat /sys/class/power_supply/BAT1/capacity)" - printf "^c$blue^  $get_capacity" + get_capacity="$(cat /sys/class/power_supply/BAT0/capacity)" + printf "^c$blue^  $get_capacity%%" } brightness() { printf "^c$red^  " - printf "^c$red^%.0f\n" $(cat /sys/class/backlight/*/brightness) + printf "^c$red^%.0f\n" "$(cat /sys/class/backlight/*/brightness)" +} + +volume() { + vol=$(amixer get Master | grep -o '[0-9]*%' | head -n 1) + muted=$(amixer get Master | grep -o '\[off\]' | head -n 1) + + if [[ "$muted" == "[off]" ]]; then + printf "^c$yellow^  Muted" # Muted glyph + else + printf "^c$green^  $vol" # Larger volume glyph + fi } mem() { @@ -43,21 +45,20 @@ mem() { } wlan() { - case "$(cat /sys/class/net/wl*/operstate 2>/dev/null)" in - up) printf "^c$black^ ^b$blue^ 󰤨 ^d^%s" " ^c$blue^Connected" ;; - down) printf "^c$black^ ^b$blue^ 󰤭 ^d^%s" " ^c$blue^Disconnected" ;; - esac + case "$(cat /sys/class/net/wl*/operstate 2>/dev/null)" in + up) printf "^c$black^ ^b$blue^   ^d^%s" " ^c$blue^Connected" ;; + down) printf "^c$black^ ^b$blue^ 睊 ^d^%s" " ^c$blue^Disconnected" ;; + esac } clock() { - printf "^c$black^ ^b$darkblue^ 󱑆 " - printf "^c$black^^b$blue^ $(date '+%H:%M') " + printf "^c$black^ ^b$darkblue^  " + printf "^c$black^^b$blue^ $(date '+%H:%M') " } +# Main loop while true; do - - [ $interval = 0 ] || [ $(($interval % 3600)) = 0 ] && updates=$(pkg_updates) - interval=$((interval + 1)) - - sleep 1 && xsetroot -name "$updates $(battery) $(brightness) $(cpu) $(mem) $(wlan) $(clock)" + updates=$(pkg_updates) # Update every loop now. Less resource intensive than checking every second. + xsetroot -name "$updates $(battery) $(brightness) $(volume) $(mem) $(wlan) $(clock)" + sleep 1 done From adcfea8c8ea1c8a4958970725c24eeb3e1a77b2b Mon Sep 17 00:00:00 2001 From: Prateek Shukla Date: Mon, 23 Dec 2024 20:59:53 +0530 Subject: [PATCH 2/2] Update bar.sh Kept the default glyphs removed the volume applet changed update status to update every 1 hour --- scripts/bar.sh | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/scripts/bar.sh b/scripts/bar.sh index 24de48e5..291a8327 100755 --- a/scripts/bar.sh +++ b/scripts/bar.sh @@ -28,17 +28,6 @@ brightness() { printf "^c$red^%.0f\n" "$(cat /sys/class/backlight/*/brightness)" } -volume() { - vol=$(amixer get Master | grep -o '[0-9]*%' | head -n 1) - muted=$(amixer get Master | grep -o '\[off\]' | head -n 1) - - if [[ "$muted" == "[off]" ]]; then - printf "^c$yellow^  Muted" # Muted glyph - else - printf "^c$green^  $vol" # Larger volume glyph - fi -} - mem() { printf "^c$blue^^b$black^  " printf "^c$blue^ $(free -h | awk '/^Mem/ { print $3 }' | sed s/i//g)" @@ -46,13 +35,13 @@ mem() { wlan() { case "$(cat /sys/class/net/wl*/operstate 2>/dev/null)" in - up) printf "^c$black^ ^b$blue^   ^d^%s" " ^c$blue^Connected" ;; - down) printf "^c$black^ ^b$blue^ 睊 ^d^%s" " ^c$blue^Disconnected" ;; + up) printf "^c$black^ ^b$blue^ 󰤨  ^d^%s" " ^c$blue^Connected" ;; + down) printf "^c$black^ ^b$blue^ 󰤭 ^d^%s" " ^c$blue^Disconnected" ;; esac } clock() { - printf "^c$black^ ^b$darkblue^  " + printf "^c$black^ ^b$darkblue^ 󱑆 " printf "^c$black^^b$blue^ $(date '+%H:%M') " } @@ -60,5 +49,5 @@ clock() { while true; do updates=$(pkg_updates) # Update every loop now. Less resource intensive than checking every second. xsetroot -name "$updates $(battery) $(brightness) $(volume) $(mem) $(wlan) $(clock)" - sleep 1 + sleep 3600 done