quotes prevent glob and word splitting + spelling

This commit is contained in:
Elias Howell 2023-01-02 13:59:13 -05:00
parent 345f4e678e
commit 19ad8e5fb4
5 changed files with 16 additions and 16 deletions

16
bar.sh
View file

@ -20,7 +20,7 @@ else
OUTPUT_CACHE="/home/$USER/.config/dwmbar/.cache/" OUTPUT_CACHE="/home/$USER/.config/dwmbar/.cache/"
fi fi
source $CONFIG_FILE source "$CONFIG_FILE"
OUTPUT="" OUTPUT=""
@ -28,7 +28,7 @@ get_bar()
{ {
for module in $MODULES; do for module in $MODULES; do
if [[ $INTERNET -eq 0 ]] || [[ $ONLINE_MODULES != *"$module"* ]];then if [[ $INTERNET -eq 0 ]] || [[ $ONLINE_MODULES != *"$module"* ]];then
module_out="$(cat $OUTPUT_CACHE$module | sed 's/\.$//g')" module_out="$(cat "$OUTPUT_CACHE""$module" | sed 's/\.$//g')"
bar="$bar$module_out" bar="$bar$module_out"
fi fi
done done
@ -41,9 +41,9 @@ run_module()
{ {
if [[ -f "$CUSTOM_DIR$1" ]] if [[ -f "$CUSTOM_DIR$1" ]]
then then
out="$($CUSTOM_DIR$1)" out="$("$CUSTOM_DIR""$1")"
else else
out="$($DEFAULT_MODULES_DIR$1)" out="$("$DEFAULT_MODULES_DIR""$1")"
fi fi
if [[ "$out" = " " ]]; then if [[ "$out" = " " ]]; then
@ -58,17 +58,17 @@ run()
{ {
for module in $MODULES; do for module in $MODULES; do
[[ ! -f "$OUTPUT_CACHE$module" ]] && touch "$OUTPUT_CACHE$module" [[ ! -f "$OUTPUT_CACHE$module" ]] && touch "$OUTPUT_CACHE$module"
pgrep $module &> /dev/null pgrep "$module" &> /dev/null
notrunning=$([[ $? -eq 1 ]]) notrunning=$([[ $? -eq 1 ]])
if $notrunning && [[ $INTERNET -eq 0 ]]; then if $notrunning && [[ $INTERNET -eq 0 ]]; then
run_module $module run_module "$module"
elif $notrunning && [[ $INTERNET -eq 1 ]]; then elif $notrunning && [[ $INTERNET -eq 1 ]]; then
[[ "$ONLINE_MODULES" != *"$module"* ]] && run_module $module [[ "$ONLINE_MODULES" != *"$module"* ]] && run_module "$module"
fi fi
done done
get_bar get_bar
sleep $DELAY; sleep "$DELAY";
} }
run run

2
config
View file

@ -15,6 +15,6 @@ CUSTOM_DIR="/home/$USER/.config/dwmbar/modules/custom/"
# Separator between modules # Separator between modules
SEPARATOR=" | " SEPARATOR=" | "
# Padding at the end and beggining of the status bar # Padding at the end and beginning of the status bar
RIGHT_PADDING=" " RIGHT_PADDING=" "
LEFT_PADDING=" " LEFT_PADDING=" "

View file

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
# Prints out the total disk memory and the availeable memory # Prints out the total disk memory and the available memory
PREFIX=' ' PREFIX=' '

View file

@ -6,13 +6,13 @@ PREFIX=' '
get_down_traffic() get_down_traffic()
{ {
RECIEVE1=0 RECEIVE1=0
RECIEVE2=0 RECEIVE2=0
IFACES=$(ip -o link show | awk -F': ' '{print $2}') IFACES=$(ip -o link show | awk -F': ' '{print $2}')
for IFACE in $IFACES; do for IFACE in $IFACES; do
if [ $IFACE != "lo" ]; then if [ $IFACE != "lo" ]; then
RECIEVE1=$(($(ip -s -c link show $IFACE | tail -n3 | head -n 1 | cut -d " " -f5) + $RECIEVE1)) RECEIVE1=$(($(ip -s -c link show $IFACE | tail -n3 | head -n 1 | cut -d " " -f5) + $RECEIVE1))
fi fi
done done
@ -21,11 +21,11 @@ get_down_traffic()
IFACES=$(ip -o link show | awk -F': ' '{print $2}') IFACES=$(ip -o link show | awk -F': ' '{print $2}')
for IFACE in $IFACES; do for IFACE in $IFACES; do
if [ $IFACE != "lo" ]; then if [ $IFACE != "lo" ]; then
RECIEVE2=$(($(ip -s -c link show $IFACE | tail -n3 | head -n 1 | cut -d " " -f5) + $RECIEVE2)) RECEIVE2=$(($(ip -s -c link show $IFACE | tail -n3 | head -n 1 | cut -d " " -f5) + $RECEIVE2))
fi fi
done done
echo "$PREFIX$(expr $(expr $RECIEVE2 - $RECIEVE1 ) / 1000)KB/s" echo "$PREFIX$(expr $(expr $RECEIVE2 - $RECEIVE1 ) / 1000)KB/s"
} }
get_down_traffic get_down_traffic

View file

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
# Prints out your public IP adress # Prints out your public IP address
# Depends on curl # Depends on curl
PREFIX=' ' PREFIX=' '