diff --git a/.local/bin/statusbar/sb-battery b/.local/bin/statusbar/sb-battery index fd94ef3fc..dcf9f9a13 100755 --- a/.local/bin/statusbar/sb-battery +++ b/.local/bin/statusbar/sb-battery @@ -5,6 +5,9 @@ cyan="\033[36m" green="\033[32m" white="\033[37m" reset="\033[0m" + +[ -z "$(ls /sys/class/power_supply)" ] && exit 0 + for battery in /sys/class/power_supply/BAT?*; do pidof -x sbd-battery >/dev/null 2>&1 || sbd-battery "$battery" >/dev/null 2>&1 & [ -n "${capacity+x}" ] && printf " " diff --git a/.local/bin/statusbar/sb-cpu b/.local/bin/statusbar/sb-cpu index a21d9b664..00784c120 100755 --- a/.local/bin/statusbar/sb-cpu +++ b/.local/bin/statusbar/sb-cpu @@ -9,11 +9,11 @@ orange="\033[33m" cache=/tmp/cpubarscache temp=$(sensors | awk '/CPU/ {printf ("%.f°C", $2)}' | tr -d "+") -[ -n "$temp" ] && temp=" $temp " -stats=$(awk '/cpu[0-9]+/ {printf "%d %d %d\n", substr($1,4), ($2 + $3 + $4 + $5), $5 }' /proc/stat) +[ -n "$temp" ] && temp="$temp " +stats=$(awk '/cpu[0-9]+/ {printf "%d %d %d\n", substr($1,4), ($2 + $3 + $4 + $5), $5 }' /proc/stat 2>/dev/null) [ ! -f $cache ] && echo "$stats" >"$cache" old=$(cat "$cache") -printf "%b" "$big$normal$temp" +printf "%b" "$big $normal$temp" echo "$stats" | while read -r row; do id=${row%% *} rest=${row#* } diff --git a/.local/bin/statusbar/sb-packages b/.local/bin/statusbar/sb-packages index b8879c126..e219909dc 100755 --- a/.local/bin/statusbar/sb-packages +++ b/.local/bin/statusbar/sb-packages @@ -4,18 +4,5 @@ big="\033[11m" reset="\033[0m" icon="" -if command -v pacman 1>/dev/null 2>&1; then - num="$(pacman -Qu | grep -Fcv "[ignored]")" - [ "$num" -gt 0 ] && printf "%b" "$big$icon$reset$num" -fi - -if command -v apt 1>/dev/null 2>&1; then - vals=$(apt upgrade -sy 2>/dev/null | grep -m1 '^[0-9]\+ upgraded,' | tr -cd '0-9 ' | tr ' ' '\n' | grep '[0-9]\+' | xargs) - - for i in $vals; do - [ "$i" != 0 ] && updates_available=yes - out="$out$i/" - done - - [ -n "$updates_available" ] && printf "%b" "$big$icon$reset $(echo "$out" | sed 's/\/$//')" || exit 0 -fi +num="$(\xbps-install -Sun | grep -c "update")" +[ "$num" -gt 0 ] && printf "%b" "$big$icon$reset $num\n" diff --git a/.local/bin/upgrades b/.local/bin/upgrades index 2f956c049..8fb6afefd 100755 --- a/.local/bin/upgrades +++ b/.local/bin/upgrades @@ -2,28 +2,9 @@ BOLD='\033[1m' BLUE='\033[34m' -NC='\033[0m' -# apt ----------------------------------------------------------------------------- -# create the file /etc/apt/apt.conf.d/80statusbar containing the following -# DPkg::Post-Invoke {"/usr/bin/pkill -RTMIN+8 dwmblocks";}; +sudo xbps-install -Syu && pkill -RTMIN+8 "${STATUSBAR:-dwmblocks}" -command -v apt 1>/dev/null 2>&1 && sudo apt upgrade - -# void ---------------------------------------------------------------------------- -# Void doesn't have post-install hooks at all, and including pkills in the package hooks isn't feasible -# Instead pkill is called in this script. Manually running updates will cause the status bar to desync - -command -v xbps-install 1>/dev/null 2>&1 && sudo xbps-install -Syu && pkill -RTMIN+8 "${STATUSBAR:-dwmblocks}" - -# newversion=$(grep -oP '(?<=\* version: )\d\d\d' "$(DISPLAY=invalid "$DOTS_DIR"/.local/share/firefox/updater.sh -r 2>/dev/null | grep -oP '(?<=Warning: user.js was saved to temporary file )/tmp/tmp\.\w+\.js')") -# oldversion=$(grep -oP '(?<=\* version: )\d\d\d' "$DOTS_DIR"/.local/share/firefox/user.js) -# -# if [ $newversion -gt $oldversion ]; then -# printf "%b" "$BOLD${BLUE}Updating arkenfox...$NC\n" -# "$DOTS_DIR/.local/share/firefox/updater.sh" -b -# fi - -printf "%b" "$BOLD${BLUE}Upgrade complete.\nPress to exit window.\n" +printf "%b" "${BOLD}${BLUE}Upgrade complete.\nPress to exit window.\n" read -r _ exit