diff --git a/.local/bin/statusbar/sb-battery b/.local/bin/statusbar/sb-battery index aa579582e..7de345b8a 100755 --- a/.local/bin/statusbar/sb-battery +++ b/.local/bin/statusbar/sb-battery @@ -1,10 +1,10 @@ #!/bin/sh -red="\e[31m" -orange="\e[33m" -cyan="\e[36m" -green="\e[32m" -white="\e[37m" -reset="\e[0m" +red="\033[31m" +orange="\033[33m" +cyan="\033[36m" +green="\033[32m" +white="\033[37m" +reset="\033[0m" 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 " " @@ -65,5 +65,5 @@ for battery in /sys/class/power_supply/BAT?*; do ;; *) exit 1 ;; esac - printf "$color%s$reset %d" "$icon" "$capacity" + printf "%b" "$color$icon$reset $capacity" done && printf "\\n" diff --git a/.local/bin/statusbar/sb-cpu b/.local/bin/statusbar/sb-cpu index fc2f87955..0e9e3e80d 100755 --- a/.local/bin/statusbar/sb-cpu +++ b/.local/bin/statusbar/sb-cpu @@ -1,3 +1,3 @@ #!/bin/sh # TODO: Add color -sensors | awk '/Core 0/ {print "\e[11mšŸŒ”\e[10m" $3}' +sensors | awk '/Core 0/ {print "\033[11mšŸŒ”\033[10m" $3}' diff --git a/.local/bin/statusbar/sb-cpubars b/.local/bin/statusbar/sb-cpubars index 5e54d3ece..342b6710f 100755 --- a/.local/bin/statusbar/sb-cpubars +++ b/.local/bin/statusbar/sb-cpubars @@ -1,9 +1,17 @@ #!/bin/sh + +reset="\033[0m" +normal="\033[10m" +big="\033[11m" +red="\033[31m" +green="\033[32m" +orange="\033[33m" + cache=/tmp/cpubarscache stats=$(awk '/cpu[0-9]+/ {printf "%d %d %d\n", substr($1,4), ($2 + $3 + $4 + $5), $5 }' /proc/stat) [ ! -f $cache ] && echo "$stats" >"$cache" old=$(cat "$cache") -printf "\e[11mļ¬™\e[10m " +printf "%b" "$bigļ¬™$normal " echo "$stats" | while read -r row; do id=${row%% *} rest=${row#* } @@ -12,15 +20,15 @@ echo "$stats" | while read -r row; do case "$(echo "$old" | awk '{if ($1 == id) printf "%d\n", (1 - (idle - $3) / (total - $2))*100 /12.5}' \ id="$id" total="$total" idle="$idle")" in - "0") printf "\e[32mā–" ;; - "1") printf "\e[32mā–‚" ;; - "2") printf "\e[32mā–ƒ" ;; - "3") printf "\e[33mā–„" ;; - "4") printf "\e[33mā–…" ;; - "5") printf "\e[33mā–†" ;; - "6" | "7" | "8") printf "\e[31mā–‡" ;; + "0") printf "%b" "$greenā–" ;; + "1") printf "%b" "$greenā–‚" ;; + "2") printf "%b" "$greenā–ƒ" ;; + "3") printf "%b" "$orangeā–„" ;; + "4") printf "%b" "$orangeā–…" ;; + "5") printf "%b" "$orangeā–†" ;; + "6" | "7" | "8") printf "%b" "$redā–‡" ;; esac done -printf "\e[0m\n" +printf "%b" "$reset\n" echo "$stats" >"$cache" diff --git a/.local/bin/statusbar/sb-disk b/.local/bin/statusbar/sb-disk index d4aa64995..e2a48b8d7 100755 --- a/.local/bin/statusbar/sb-disk +++ b/.local/bin/statusbar/sb-disk @@ -1,5 +1,9 @@ #!/bin/sh # $1 should be drive mountpoint, otherwise assumed /. + +reset="\033[0m" +big="\033[11m" + location=${1:-/} [ -d "$location" ] || exit -printf "\e[11mļŸ‰\e[10m %s\n" "$(df -h "$location" | awk ' /[0-9]/ {print $3 "/" $2}')" +printf "%b" "$bigļŸ‰$reset $(df -h "$location" | awk ' /[0-9]/ {print $3 "/" $2}')\n" diff --git a/.local/bin/statusbar/sb-forecast b/.local/bin/statusbar/sb-forecast index deb924ecf..7922066f3 100755 --- a/.local/bin/statusbar/sb-forecast +++ b/.local/bin/statusbar/sb-forecast @@ -3,6 +3,12 @@ # NOTE: This script takes its dwmblocks update signal as an argument so that it can refresh itself (defaults to 5) # Options can be found at https://wttr.in/:help +reset="\033[0m" +big="\033[11m" +verybig="\033[12m" +red="\033[31m" +blue="\033[34m" + weatherfile="$XDG_CACHE_HOME/weatherreport" emojifile="$XDG_CACHE_HOME/weatheremoji" url="wttr.in/$LOCATION" @@ -17,19 +23,19 @@ fresh() { [ -s "$weatherfile" ] && [ "$(stat -c %y "$weatherfile" 2>/dev/null | cut -d' ' -f1)" = "$(date '+%Y-%m-%d')" ] } readfile() { - weather="$(cat "$weatherfile")" - precipitation="$(echo "$weather" | sed '16q;d' | grep -wo "[0-9]*%" | sort -rn | head -1q)" - highlow="$(echo "$weather" | sed '13q;d' | grep -o "m\\([-+]\\)*[0-9]\\+" | sed 's/[+m]//g' | sort -g | sed -e 1b -e '$!d')" - emoji="$(cat "$emojifile")" + weather="$(cat "$weatherfile")" + precipitation="$(echo "$weather" | sed '16q;d' | grep -wo "[0-9]*%" | sort -rn | head -1q)" + highlow="$(echo "$weather" | sed '13q;d' | grep -o "m\\([-+]\\)*[0-9]\\+" | sed 's/[+m]//g' | sort -g | sed -e 1b -e '$!d')" + emoji="$(cat "$emojifile")" } output() { - readfile - printf "\e[12m%s\e[10m %s \e[34;11mļ•…\e[0m %sĀ° \e[31;11mļ•\e[0m %sĀ°\n" "$emoji" "$precipitation" $highlow + readfile + printf "%b" "$verybig$emoji$reset $precipitation $big$blueļ•…$reset $(echo $highlow | cut -d" " -f1)Ā° $big$redļ•$reset $(echo $highlow | cut -d" " -f2)Ā°\n" } if fresh; then - output + output else - getforecast && pkill -RTMIN+${1:-5} dwmblocks & - printf "ļ€” Getting Weather\n" + getforecast && pkill -RTMIN+${1:-5} dwmblocks & + printf "%b" "$bigļ€”$reset Getting Weather\n" fi diff --git a/.local/bin/statusbar/sb-internet b/.local/bin/statusbar/sb-internet index 47639e2b1..d9be7977e 100755 --- a/.local/bin/statusbar/sb-internet +++ b/.local/bin/statusbar/sb-internet @@ -1,11 +1,14 @@ #!/bin/sh shift="" +reset="\033[0m" +big="\033[11m" + if ls /sys/class/net/w*/operstate 1>/dev/null 2>&1; then for w in /sys/class/net/w*/; do percent="$(cat /proc/net/wireless | grep "$(basename "$(dirname $w/operstate)")" | tr -s ' ' | cut -d ' ' -f3 | tr -dc "[:digit:]")" grep -vxq '0x1003' "$w/flags" && wifi_icon="ļ”" || wifi_icon="$(sed "s/up/ļŖØ/;s/down/ļŖ©/;s/dormant/ļŖ©/" $w/operstate | tr -d "[:space:]")" - printf "$shift\e[11m%s\e[10m %s" "$wifi_icon" "$percent" + printf "%b" "$shift$big$wifi$icon$reset $percent" shift=" " done fi @@ -13,16 +16,16 @@ fi if ls /sys/class/net/e*/operstate 1>/dev/null 2>&1; then for e in /sys/class/net/e*/operstate; do if_icon="$(sed "s/down/ļœ/;s/up/ļœ€/" $e)" - printf "$shift\e[11m%s\e[10m" "$if_icon" + printf "%b" "$shift$big$if_icon$reset" shift=" " done fi if ls /sys/class/net/tun*/operstate 1>/dev/null 2>&1; then for _ in /sys/class/net/tun*/operstate; do - printf "$shift\e[11m%s\e[10m" "ļŖ" + printf "%b" "$shift$bigļŖ$reset" shift=" " done fi -printf "\n" +printf "%b" "\n" diff --git a/.local/bin/statusbar/sb-nettraf b/.local/bin/statusbar/sb-nettraf index 0e5f82ca8..b093b0745 100755 --- a/.local/bin/statusbar/sb-nettraf +++ b/.local/bin/statusbar/sb-nettraf @@ -1,7 +1,7 @@ #!/bin/sh -big="\e[11m" -reset="\e[10m" +big="\033[11m" +reset="\033[0m" update() { sum=0 @@ -11,9 +11,10 @@ update() { done cache=/tmp/${1##*/} [ -f "$cache" ] && read -r old <"$cache" || old=0 - printf %d\\n "$sum" >"$cache" - printf %d\\n $((sum - old)) + printf "%b" "$sum\n" >"$cache" + printf "%b" "$((sum - old))\n" } + rx=$(update /sys/class/net/[ew]*/statistics/rx_bytes) tx=$(update /sys/class/net/[ew]*/statistics/tx_bytes) -printf "$bigļ•…$reset%5sB $bigļ•$reset%5sB\\n" $(numfmt --to=iec "$rx" "$tx") +printf "%b%5sB %b%5sB%b" "$bigļ•…$reset" "$(numfmt --to=iec "$rx")" "$bigļ•$reset" "$(numfmt --to=iec "$tx")" "\n" diff --git a/.local/bin/statusbar/sb-packages b/.local/bin/statusbar/sb-packages index 3cc45eed8..bc551873d 100755 --- a/.local/bin/statusbar/sb-packages +++ b/.local/bin/statusbar/sb-packages @@ -1,10 +1,12 @@ #!/bin/sh -icon="\e[11mļ£–\e[10m" +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 %i" "$icon" "$num" + [ "$num" -gt 0 ] && printf "%b" "$big$icon$reset$num" fi if command -v apt 1>/dev/null 2>&1; then @@ -15,5 +17,5 @@ if command -v apt 1>/dev/null 2>&1; then out="$out$i/" done - [ -n "$updates_available" ] && printf "%b %s" "$icon" "$(echo "$out" | sed 's/\/$//')" + [ -n "$updates_available" ] && printf "%b" "$big$icon$reset $(echo "$out" | sed 's/\/$//')" fi diff --git a/.local/bin/statusbar/sb-playerctl b/.local/bin/statusbar/sb-playerctl index ca87dacd3..a017d19ef 100755 --- a/.local/bin/statusbar/sb-playerctl +++ b/.local/bin/statusbar/sb-playerctl @@ -1,7 +1,7 @@ #!/bin/sh -big="\e[11m" -reset="\e[10m" +big="\033[11m" +reset="\033[0m" pidof -x sbd-playerctl >/dev/null 2>&1 || sbd-playerctl >/dev/null 2>&1 & [ "$(playerctl status 2>&1)" = "No players found" ] && printf "%bļ±™%b" "$big" "$reset" && exit 1 diff --git a/.local/bin/statusbar/sb-volume b/.local/bin/statusbar/sb-volume index 1459f107c..a2a6cb013 100755 --- a/.local/bin/statusbar/sb-volume +++ b/.local/bin/statusbar/sb-volume @@ -1,4 +1,7 @@ #!/bin/sh +big="\033[11m" +reset="\033[0m" + # Prints the current volume or ļ± if muted. [ "$(pamixer --get-mute)" = true ] && echo "\e[11mļ±\e[10m" && exit vol="$(pamixer --get-volume)" @@ -12,6 +15,6 @@ elif [ "$vol" -gt "0" ]; then elif [ "$vol" -eq "0" ]; then icon="ļ‘¦" else - printf "\e[11mļ‘¦\e[10m ļ„Øļ„Ø" && exit + printf "%bļ‘¦%b ļ„Øļ„Ø" "\e[11m" "\e[0m" && exit fi -printf "\e[11m%s\e[10m %s\n" "$icon" "$vol" +printf "%b" "$big$icon$reset $vol\n" diff --git a/.local/bin/statusbar/sb-xkbmap b/.local/bin/statusbar/sb-xkbmap index db9306e45..a0888006b 100755 --- a/.local/bin/statusbar/sb-xkbmap +++ b/.local/bin/statusbar/sb-xkbmap @@ -1,3 +1,5 @@ #!/bin/sh # pidof -x sbd-xkbmap >/dev/null 2>&1 || sbd-xkbmap >/dev/null 2>&1 & -printf "\e[11mļ ‹\e[10m %s\n" "$(setxkbmap -query | grep -oP '(layout|variant):\s*\K\w+' | sed ':a;N;s/\n/:/')" +big="\033[11m" +reset="\033[0m" +printf "%b" "$bigļ ‹$reset $(setxkbmap -query | grep -oP '(layout|variant):\s*\K\w+' | sed ':a;N;s/\n/:/')\n"