resolved shellcheck warnings

This commit is contained in:
Tobias Schmidl 2020-09-21 08:06:51 +02:00
parent 7005c74795
commit 897e1c5940

View file

@ -1,14 +1,15 @@
#! /bin/bash #! /bin/bash
# shellcheck disable=SC2034
PURPLE_GREEN_THEME=("#762a83" "#9970ab" "#c2a5cf" "#a6dba0" "#5aae61" "#1b7837") PURPLE_GREEN_THEME=("#762a83" "#9970ab" "#c2a5cf" "#a6dba0" "#5aae61" "#1b7837")
RED_GREEN_THEME=("#d73027" "#fc8d59" "#fee08b" "#d9ef8b" "#91cf60" "#1a9850") RED_GREEN_THEME=("#d73027" "#fc8d59" "#fee08b" "#d9ef8b" "#91cf60" "#1a9850")
ORIGINAL_THEME=("#acacac" "#ff0101" "#cc673b" "#ce8458" "#6bbb15" "#0ed812") ORIGINAL_THEME=("#acacac" "#ff0101" "#cc673b" "#ce8458" "#6bbb15" "#0ed812")
COLORS=(${RED_GREEN_THEME[@]}) COLORS=("${RED_GREEN_THEME[@]}")
LOADAVG=$(cut -d' ' -f 1 /proc/loadavg) LOADAVG=$(cut -d' ' -f 1 /proc/loadavg)
CORES=$(grep -c processor /proc/cpuinfo) CORES=$(grep -c processor /proc/cpuinfo)
LOAD_PER_CORE=$(echo "${LOADAVG} 100 * $CORES / p" | dc) LOAD_PER_CORE=$(echo "${LOADAVG} 100 * ${CORES} / p" | dc)
case $LOAD_PER_CORE in case ${LOAD_PER_CORE} in
[0-9]|[0-4][0-9]) [0-9]|[0-4][0-9])
COLOR="${COLORS[5]}" COLOR="${COLORS[5]}"
;; ;;
@ -28,32 +29,34 @@ case $LOAD_PER_CORE in
COLOR="${COLORS[0]}" COLOR="${COLORS[0]}"
;; ;;
esac esac
echo "${LOADAVG} | color=$COLOR" echo "${LOADAVG} | color=${COLOR}"
echo "------" echo "------"
[ "$ARGOS_MENU_OPEN" == "false" ] && exit 0; # shellcheck disable=SC2154
[ "${ARGOS_MENU_OPEN}" == "false" ] && exit 0;
echo "<span size=\"large\" font_weight=\"bold\">Disks</span>" echo "<span size=\"large\" font_weight=\"bold\">Disks</span>"
IFS=$'\n'; IFS=$'\n';
for a in `df -h | sed -n '/\/snap/d;/% *\//p' | sort -n --reverse -k 5,5 | head -n 4`; do echo "${a} | font=monospace | size=8 | trim=false"; done; for a in $(df -h | sed -n '/\/snap/d;/% *\//p' | sort -n --reverse -k 5,5 | head -n 4); do echo "${a} | font=monospace | size=8 | trim=false"; done;
echo "------" echo "------"
echo "<span size=\"large\" font_weight=\"bold\">Core speeds</span>" echo "<span size=\"large\" font_weight=\"bold\">Core speeds</span>"
LINE=`for a in /sys/devices/system/cpu/cpufreq/policy*; do echo -n "$(($(<$a/scaling_cur_freq)/1000))/$(($(<$a/scaling_max_freq)/1000)) :: "; done;` LINE=$(for a in /sys/devices/system/cpu/cpufreq/policy*; do echo -n "$(($(< "${a}"/scaling_cur_freq)/1000))/$(($(< "${a}"/scaling_max_freq)/1000)) :: "; done;)
echo "${LINE%::*}| font=monospace | size=8" echo "${LINE%::*}| font=monospace | size=8"
echo "------" echo "------"
echo "<span size=\"large\" font_weight=\"bold\">Temperature</span>" echo "<span size=\"large\" font_weight=\"bold\">Temperature</span>"
LINE=$(for current_node in `find /sys/devices -ipath '*hwmon*' -name 'temp*input'`; \ # shellcheck disable=SC2044
LINE=$(for current_node in $(find /sys/devices -ipath '*hwmon*' -name 'temp*input'); \
do \ do \
input_temp=`<$current_node`; \ input_temp=$(< "${current_node}"); \
if [ "$input_temp" -eq "$input_temp" ] 2> /dev/null; \ if [ "${input_temp}" -eq "${input_temp}" ] 2> /dev/null; \
then then
input_name=`<${current_node%/*}/name`; \ input_name=$(< "${current_node%/*}"/name); \
[ -n "$input_name" ] && echo -n "$input_name "; \ [ -n "${input_name}" ] && echo -n "${input_name} "; \
echo -n "$(($input_temp / 1000))"; \ echo -n "$((input_temp / 1000))"; \
input_crit=`cat ${current_node%input}crit 2> /dev/null`; \ input_crit=$(< "${current_node%input}"crit 2> /dev/null); \
[ "$input_crit" -eq "$input_crit" ] 2> /dev/null && echo -n "/$(($input_crit / 1000))"; \ [ "${input_crit}" -eq "${input_crit}" ] 2> /dev/null && echo -n "/$((input_crit / 1000))"; \
echo -n " :: "; \ echo -n " :: "; \
fi; \ fi; \
done) done)
@ -63,10 +66,10 @@ echo "------"
echo "<span size=\"large\" font_weight=\"bold\">top</span>" echo "<span size=\"large\" font_weight=\"bold\">top</span>"
( \ ( \
export LANG=C; \ export LANG=C; \
for a in `top -o TIME -bcn1 -w150 | grep -vi "\b[KkMmGg]ib\b" | head -n 10`; do echo "${a} | font=monospace | size=8 | trim=false"; done; \ for a in $(top -o TIME -bcn1 -w150 | grep -vi "\b[KkMmGg]ib\b" | head -n 10); do echo "${a} | font=monospace | size=8 | trim=false"; done; \
) )
echo "------" echo "------"
echo "<span size=\"large\" font_weight=\"bold\">dmesg</span>" echo "<span size=\"large\" font_weight=\"bold\">dmesg</span>"
for a in `dmesg --color=always -Tx | fold -w 160 -s - | tail -n 10`; do echo "${a} | font=monospace | size=8"; done; for a in $(dmesg --color=always -Tx | fold -w 160 -s - | tail -n 10); do echo "${a} | font=monospace | size=8"; done;
#df -h | sort -n --reverse -k 5,5 #df -h | sort -n --reverse -k 5,5