*: Wrap lines at 80 columns where appropriate
Wrap lines at 80 columns where appropriate and I had the energy to think about how/where to wrap. There are still lines longer than that, which I plan to wrap in the future. But that is enough for now.
This commit is contained in:
@@ -5,14 +5,24 @@ bluetooth_print() {
|
||||
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)
|
||||
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)
|
||||
|
||||
if echo "$device_info" | grep -q "Connected: yes"; then
|
||||
device_alias=$(echo "$device_info" | grep "Alias" | cut -d ' ' -f 2-)
|
||||
device_alias=$(
|
||||
echo "$device_info" \
|
||||
| grep "Alias" \
|
||||
| cut -d ' ' -f 2-
|
||||
)
|
||||
|
||||
if [[ $counter -gt 0 ]]; then
|
||||
printf ", %s" "$device_alias"
|
||||
@@ -39,12 +49,24 @@ bluetooth_toggle() {
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
|
||||
command -v playerctl >/dev/null 2>&1 || { printf "playerctl not found.\n" >&2; exit 1; }
|
||||
|
||||
# metadata="$(playerctl metadata --format '{{status}} {{artist}} - {{title}} ({{duration(position)}}|{{duration(mpris:length)}})')"
|
||||
metadata="$(playerctl metadata --format '{{status}} {{artist}}' 2>/dev/null)"
|
||||
title="$(playerctl metadata --format '{{title}}' 2>/dev/null)"
|
||||
duration="$(playerctl metadata --format '({{duration(position)}}|{{duration(mpris:length)}})' 2>/dev/null)"
|
||||
duration="$(2>/dev/null playerctl metadata \
|
||||
--format '({{duration(position)}}|{{duration(mpris:length)}})'
|
||||
)"
|
||||
|
||||
|
||||
if [ -n "$metadata" ] && [ "$metadata" != "No players found" ]; then
|
||||
|
||||
@@ -6,8 +6,8 @@ if [ -n "$connection" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# [o] is a hack to not grep the grep-command
|
||||
# see: https://stackoverflow.com/questions/9375711/more-elegant-ps-aux-grep-v-grep
|
||||
# [o] is a hack to not grep the grep-command. See:
|
||||
# https://stackoverflow.com/questions/9375711/more-elegant-ps-aux-grep-v-grep
|
||||
if ps ax | grep -q "[o]penvpn"; then
|
||||
echo "VPN"
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user