26 lines
676 B
Bash
Executable File
26 lines
676 B
Bash
Executable File
#!/bin/sh
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
# Copyright (C) 2025 Amlogic, Inc. All rights reserved
|
|
|
|
[ -r "/etc/default/pipewire" ] && . "/etc/default/pipewire"
|
|
if [ -n "$PIPEWIRE_RUN" ]; then
|
|
export XDG_RUNTIME_DIR="$PIPEWIRE_RUN"
|
|
fi
|
|
|
|
SCRIPT_NAME=$(basename "$0" .sh)
|
|
LOCKDIR="/tmp/${SCRIPT_NAME}.lockdir"
|
|
|
|
if ! mkdir "$LOCKDIR" 2>/dev/null; then
|
|
echo "$0 script is executing now"
|
|
exit 1
|
|
fi
|
|
|
|
# use trap to clean lockdir when exit
|
|
trap "rm -rf '$LOCKDIR'" EXIT
|
|
|
|
pw-link -lI | grep -E "^\s+[0-9]+\s+\|" | grep "bluez_output\.00_00_00_00_00_00" | \
|
|
awk '{print $1}' | while read link_id; do
|
|
echo "Disconnecting link $link_id"
|
|
pw-link -d "$link_id"
|
|
done
|