diff options
| author | 0scar <qgt268@alumni.ku.dk> | 2021-07-08 13:42:12 +0000 |
|---|---|---|
| committer | 0scar <qgt268@alumni.ku.dk> | 2021-07-08 13:42:12 +0000 |
| commit | 2a4b3c6f21a92fe0f7f01c466ab37e795c399d03 (patch) | |
| tree | e7c331004fbf89e139731360efb13eafc1ec04db /.local/bin/statusbar | |
| parent | dc8250ac7c2a2da15c34c354fa7d83a0dfed00e0 (diff) | |
Update statusbar scripts
Diffstat (limited to '.local/bin/statusbar')
| -rwxr-xr-x | .local/bin/statusbar/batinfo | 8 | ||||
| -rwxr-xr-x | .local/bin/statusbar/checkupdates | 1 | ||||
| -rwxr-xr-x | .local/bin/statusbar/cpuinfo | 31 | ||||
| -rwxr-xr-x | .local/bin/statusbar/netinfo | 2 |
4 files changed, 20 insertions, 22 deletions
diff --git a/.local/bin/statusbar/batinfo b/.local/bin/statusbar/batinfo index 317e52d..86ef565 100755 --- a/.local/bin/statusbar/batinfo +++ b/.local/bin/statusbar/batinfo @@ -17,7 +17,7 @@ power=$(echo "${status}" | awk '/Battery [0-9]+: [A-Z]/{s+=$4;c++}; END{printf " icon='?' if [[ -z $(echo $status | sed -n '/on-line/p') ]]; then case "${power%.*}" in - 100 | 9[0-9]) icon='\uf578' ;; + 100 | 9[0-9]) icon='\x0d\uf578\x0b' ;; 8[0-9]) icon='\uf581';; 7[0-9]) icon='\uf580';; 6[0-9]) icon='\uf57f';; @@ -25,11 +25,11 @@ if [[ -z $(echo $status | sed -n '/on-line/p') ]]; then 4[0-9]) icon='\uf57d';; 3[0-9]) icon='\uf57c';; 2[0-9]) icon='\uf57b';; - 1[0-9]) icon='\uf57a';; - [0-9]) icon='\uf579';; + 1[0-9]) icon='\x0e\uf57a\x0b';; + [0-9]) icon='\x1c\uf579\x0b';; esac else icon='\uf583' fi -echo -e "$icon $power" +echo -en "$icon $power" diff --git a/.local/bin/statusbar/checkupdates b/.local/bin/statusbar/checkupdates index dfcec84..609a762 100755 --- a/.local/bin/statusbar/checkupdates +++ b/.local/bin/statusbar/checkupdates @@ -12,6 +12,7 @@ case $ARG in else notify-send "Available updates" "No available updates" fi;; + 3) doas /usr/bin/pacman -Sy;; esac [ -z "${updates}" ] && exit diff --git a/.local/bin/statusbar/cpuinfo b/.local/bin/statusbar/cpuinfo index de53f22..05ab3de 100755 --- a/.local/bin/statusbar/cpuinfo +++ b/.local/bin/statusbar/cpuinfo @@ -4,31 +4,28 @@ set -e ARG=${1:-$BLOCK_BUTTON} case $ARG in - 1) notify-send --urgency=low \ - "Process status" \ - "$(ps -eo pid,pcpu,size,comm \ - | sort -rnk 3 \ - | awk '{printf "% 8s% 8s% 8s ", $1, $2, $3; - $1="";$2="";$3=""; - print $0; c++} - c>10 {exit}')" + 1) notify-send --urgency=low \ + "Process status" \ + "$(ps k-c -eo pid,pcpu,comm | head -10 \ + | sed -E 's/ +/ /g;s/^ +//' \ + | column -tl 3 -R 1,2 -s ' ')" ;; - 3) notify-send --urgency=low \ + 3) notify-send --urgency=low \ "Process status" \ - "$(ps -eo pid,pcpu,size,cmd \ - | sort -rnk 3 \ - | cut -b -45 \ - | awk '{printf "% 8s% 8s% 8s ", $1, $2, $3; - $1="";$2="";$3=""; - print $0; c++} - c>10 {exit}')" + "$(ps k-vsz -eo pid,pcpu,vsz,comm \ + | head -10 \ + | awk 'NR>1 {$3 = int($3/1024)"M";}{print;}' \ + | sed -E 's/ +/ /g;s/^ +//' \ + | column -tl 4 -R 1,2,3 -s ' ')" ;; esac # Thermals # "Never cat something into awk", yeah, but it won't function properly if it # encounters a missing `/temp`-file. -TEMP=$(cat /sys/class/thermal/thermal_zone*/temp 2>/dev/null | awk '{s+=$1}END{printf "%.1f", s / (1000*NR)}' ) +TEMP="$(cat /sys/class/thermal/thermal_zone*/temp 2>/dev/null)" +TEMP="$(echo "${TEMP}" | awk '{s+=$1}END{printf "%.1f", s / (1000*NR)}' )" +# Color red if temp > 45 TEMP=`(( $(echo "$TEMP > 45" | bc -l) )) && echo -en "\x0c${TEMP}\x0b" || echo -en "$TEMP"` # Load diff --git a/.local/bin/statusbar/netinfo b/.local/bin/statusbar/netinfo index 62c3619..4aa1bbe 100755 --- a/.local/bin/statusbar/netinfo +++ b/.local/bin/statusbar/netinfo @@ -30,7 +30,7 @@ if [ -z "$(echo -e "${netstatus}" | sed -En '/up$/p' | tr -d '\n')" ]; then echo -en '\x0c\uf701' else echo -en '\x0d' - echo -en $(echo -n "${netstatus}" | sed -En 's/^(w[^ ]+).*up/\\uf1eb/p;s/^(e[^ ]+).*up/\\uf700/p') + echo -en $(echo -n "${netstatus}" | sed -En 's/^(w[^ ]+).*up/\\ufaa8/p;s/^(e[^ ]+).*up/\\uf700/p') fi echo -en '\x0b' |
