Browse Source

Prevent globbing and word splitting

master
Riyyi 5 years ago
parent
commit
9e1686fd99
  1. 6
      .scripts/panel/battery.sh
  2. 10
      .scripts/panel/wifi.sh

6
.scripts/panel/battery.sh

@ -2,8 +2,8 @@
BAT_INFO=${BLOCK_INSTANCE:-"$(acpi -b | grep ': [^Unknown]')"} BAT_INFO=${BLOCK_INSTANCE:-"$(acpi -b | grep ': [^Unknown]')"}
CAPACITY=$(echo $BAT_INFO | awk '{ print int($4) }') CAPACITY=$(echo "$BAT_INFO" | awk '{ print int($4) }')
TIME="$(echo $BAT_INFO | awk '{ print substr($5, 0, length($5) - 3) }')" TIME="$(echo "$BAT_INFO" | awk '{ print substr($5, 0, length($5) - 3) }')"
CHARACTER=":" CHARACTER=":"
if [ "$TIME" != "" ] && [ "${TIME#*$CHARACTER}" != "$TIME" ]; then if [ "$TIME" != "" ] && [ "${TIME#*$CHARACTER}" != "$TIME" ]; then
@ -13,7 +13,7 @@ else
fi fi
COLOR="-" COLOR="-"
if [ "$(echo $BAT_INFO | awk '{ print $6 }')" = "remaining" ]; then if [ "$(echo "$BAT_INFO" | awk '{ print $6 }')" = "remaining" ]; then
if [ "$CAPACITY" -ge "80" ]; then if [ "$CAPACITY" -ge "80" ]; then
ICON="" ICON=""
elif [ "$CAPACITY" -ge "60" ]; then elif [ "$CAPACITY" -ge "60" ]; then

10
.scripts/panel/wifi.sh

@ -4,8 +4,8 @@ ICON=""
WIRELESS="${1:-wlan0}" WIRELESS="${1:-wlan0}"
if [ "$NOTIFY" = "1" ]; then if [ "$NOTIFY" = "1" ]; then
SSID="$(iw dev $WIRELESS link | awk '/SSID/ { print $2 }')" SSID="$(iw dev "$WIRELESS" link | awk '/SSID/ { print $2 }')"
IP="$(ip a show $WIRELESS \ IP="$(ip a show "$WIRELESS" \
| awk '/inet / { print substr($2, 0, length($2) - 3) }')" | awk '/inet / { print substr($2, 0, length($2) - 3) }')"
notify-send -r 3 "Wifi" "\ notify-send -r 3 "Wifi" "\
@ -14,13 +14,13 @@ SSID: $SSID
IP: $IP" IP: $IP"
else else
COLOR="-" COLOR="-"
if [ ! -d /sys/class/net/${WIRELESS}/wireless ] || if [ ! -d /sys/class/net/"$WIRELESS"/wireless ] ||
[ "$(cat /sys/class/net/$WIRELESS/operstate)" = 'down' ]; then [ "$(cat /sys/class/net/"$WIRELESS"/operstate)" = 'down' ]; then
COLOR="$COLOR7" COLOR="$COLOR7"
DISPLAY="$ICON" DISPLAY="$ICON"
else else
QUALITY=$(grep $WIRELESS /proc/net/wireless | \ QUALITY=$(grep "$WIRELESS" /proc/net/wireless | \
awk '{ print int($3 * 100 / 70) }') awk '{ print int($3 * 100 / 70) }')
COLOR="$COLOR15" COLOR="$COLOR15"

Loading…
Cancel
Save