*: Use tabs for indentation where appropriate
I am a big supporter of the approach to indent with tabs and align with
spaces. (Read [here][1] f.e.) Thus at some places a simple `s/ {4}/\t/g`
(replace 4 with whatever fits) is not enough and a bit more thought is
needed. Because of that there are still places where I plan to
substitute the whitespace in the future.
This patch contains exclusively whitespace changes. Check for yourself
with `git diff --ignore-all-space`.
[1]: https://dmitryfrank.com/articles/indent_with_tabs_align_with_spaces
This commit is contained in:
@@ -2,89 +2,89 @@
|
||||
# See https://github.com/polybar/polybar-scripts/pull/237
|
||||
|
||||
bluetooth_print() {
|
||||
bluetoothctl | while read -r; do
|
||||
if [[ "$(systemctl is-active "bluetooth.service")" = "active" ]]; then
|
||||
bluetoothctl | while read -r; do
|
||||
if [[ "$(systemctl is-active "bluetooth.service")" = "active" ]]; then
|
||||
|
||||
devices_paired=$(
|
||||
echo paired-devices \
|
||||
| bluetoothctl \
|
||||
| sed -n '/paired-devices/,$p' \
|
||||
| grep Device \
|
||||
| cut -d ' ' -f 2
|
||||
)
|
||||
counter=0
|
||||
devices_paired=$(
|
||||
echo paired-devices \
|
||||
| bluetoothctl \
|
||||
| sed -n '/paired-devices/,$p' \
|
||||
| grep Device \
|
||||
| cut -d ' ' -f 2
|
||||
)
|
||||
counter=0
|
||||
|
||||
echo "$devices_paired" | while read -r line; do
|
||||
device_info=$(echo "info $line" | bluetoothctl)
|
||||
echo "$devices_paired" | while read -r line; do
|
||||
device_info=$(echo "info $line" | bluetoothctl)
|
||||
|
||||
if echo "$device_info" | grep -q "Connected: yes"; then
|
||||
device_alias=$(
|
||||
echo "$device_info" \
|
||||
| grep "Alias" \
|
||||
| cut -d ' ' -f 2-
|
||||
)
|
||||
if echo "$device_info" | grep -q "Connected: yes"; then
|
||||
device_alias=$(
|
||||
echo "$device_info" \
|
||||
| grep "Alias" \
|
||||
| cut -d ' ' -f 2-
|
||||
)
|
||||
|
||||
if [[ $counter -gt 0 ]]; then
|
||||
printf ", %s" "$device_alias"
|
||||
else
|
||||
printf ": %s" "$device_alias"
|
||||
fi
|
||||
if [[ $counter -gt 0 ]]; then
|
||||
printf ", %s" "$device_alias"
|
||||
else
|
||||
printf ": %s" "$device_alias"
|
||||
fi
|
||||
|
||||
counter=$((counter + 1))
|
||||
fi
|
||||
done
|
||||
counter=$((counter + 1))
|
||||
fi
|
||||
done
|
||||
|
||||
if echo show | bluetoothctl | grep -q "Powered: no"; then
|
||||
if echo show | bluetoothctl | grep -q "Powered: no"; then
|
||||
printf ''
|
||||
fi
|
||||
printf '\n'
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
done
|
||||
printf '\n'
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
bluetooth_toggle() {
|
||||
if echo show | bluetoothctl | grep -q "Powered: no"; then
|
||||
echo "power on" | bluetoothctl >> /dev/null
|
||||
sleep 1
|
||||
if echo show | bluetoothctl | grep -q "Powered: no"; then
|
||||
echo "power on" | bluetoothctl >> /dev/null
|
||||
sleep 1
|
||||
|
||||
devices_paired=$(
|
||||
echo paired-devices
|
||||
| bluetoothctl \
|
||||
| sed -n '/paired-devices/,$p' \
|
||||
| grep Device \
|
||||
| cut -d ' ' -f 2
|
||||
)
|
||||
echo "$devices_paired" | while read -r line; do
|
||||
echo "connect $line" | bluetoothctl >> /dev/null
|
||||
done
|
||||
else
|
||||
devices_paired=$(
|
||||
echo paired-devices \
|
||||
| bluetoothctl \
|
||||
| sed -n '/paired-devices/,$p' \
|
||||
| grep Device \
|
||||
| cut -d ' ' -f 2
|
||||
)
|
||||
echo "$devices_paired" | while read -r line; do
|
||||
device_info=$(echo "info $line" | bluetoothctl)
|
||||
devices_paired=$(
|
||||
echo paired-devices
|
||||
| bluetoothctl \
|
||||
| sed -n '/paired-devices/,$p' \
|
||||
| grep Device \
|
||||
| cut -d ' ' -f 2
|
||||
)
|
||||
echo "$devices_paired" | while read -r line; do
|
||||
echo "connect $line" | bluetoothctl >> /dev/null
|
||||
done
|
||||
else
|
||||
devices_paired=$(
|
||||
echo paired-devices \
|
||||
| bluetoothctl \
|
||||
| sed -n '/paired-devices/,$p' \
|
||||
| grep Device \
|
||||
| cut -d ' ' -f 2
|
||||
)
|
||||
echo "$devices_paired" | while read -r line; do
|
||||
device_info=$(echo "info $line" | bluetoothctl)
|
||||
|
||||
if echo "$device_info" | grep -q "Connected: yes"; then
|
||||
echo "disconnect $line" | bluetoothctl >> /dev/null
|
||||
fi
|
||||
done
|
||||
if echo "$device_info" | grep -q "Connected: yes"; then
|
||||
echo "disconnect $line" | bluetoothctl >> /dev/null
|
||||
fi
|
||||
done
|
||||
|
||||
echo "power off" | bluetoothctl >> /dev/null
|
||||
fi
|
||||
echo "power off" | bluetoothctl >> /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
--toggle)
|
||||
bluetooth_toggle
|
||||
;;
|
||||
*)
|
||||
bluetooth_print
|
||||
;;
|
||||
--toggle)
|
||||
bluetooth_toggle
|
||||
;;
|
||||
*)
|
||||
bluetooth_print
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
connection="$(nmcli con show --active | awk '$3 ~ /^(vpn|tun)$/ { print $1 }')"
|
||||
if [ -n "$connection" ]; then
|
||||
echo "VPN: $connection"
|
||||
exit 0
|
||||
echo "VPN: $connection"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# [o] is a hack to not grep the grep-command. See:
|
||||
|
||||
Reference in New Issue
Block a user