Skip to content

Commit 8ff7467

Browse files
committed
just: Cleanly remove folder in configure-bluetooth-headset-profile
1 parent 2858b76 commit 8ff7467

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

files/justfiles/gidro-os.just

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,10 @@ configure-bluetooth-headset-profile ACTION="prompt":
281281
#!/usr/bin/env bash
282282
source /usr/lib/ujust/ujust.sh
283283
CURRENT_STATE="Enabled"
284-
if [ -f "/etc/wireplumber/wireplumber.conf.d/51-disable-bluetooth-headphone-profile-switch.conf" ]; then
284+
FILE_CONF="/usr/share/bluebuild/gidro-os/51-disable-bluetooth-headphone-profile-switch.conf"
285+
WIREPLUMBER_DIR="/etc/wireplumber/wireplumber.conf.d"
286+
WIREPLUMBER_FILE="51-disable-bluetooth-headphone-profile-switch.conf"
287+
if [ -f "${WIREPLUMBER_DIR}/${WIREPLUMBER_FILE}" ]; then
285288
CURRENT_STATE="Disabled"
286289
fi
287290
OPTION={{ ACTION }}
@@ -299,17 +302,20 @@ configure-bluetooth-headset-profile ACTION="prompt":
299302
exit 0
300303
fi
301304
if [ "${OPTION,,}" == "disable" ]; then
302-
if ! [ -f "/etc/wireplumber/wireplumber.conf.d/51-disable-bluetooth-headphone-profile-switch.conf" ]; then
303-
sudo mkdir -p "/etc/wireplumber/wireplumber.conf.d/"
304-
sudo cp "/usr/share/bluebuild/gidro-os/51-disable-bluetooth-headphone-profile-switch.conf" "/etc/wireplumber/wireplumber.conf.d/51-disable-bluetooth-headphone-profile-switch.conf"
305+
if ! [ -f "${WIREPLUMBER_DIR}/${WIREPLUMBER_FILE}" ]; then
306+
sudo mkdir -p "${WIREPLUMBER_DIR}"
307+
sudo cp "${FILE_CONF}" "${WIREPLUMBER_DIR}/${WIREPLUMBER_FILE}"
305308
systemctl --user restart wireplumber
306309
echo 'Disable Bluetooth headset profile setting applied.'
307310
else
308311
printf "\e[1;31mERROR: Bluetooth headset profile is already disabled, no change is made.\e[0m\n" 1>&2
309312
fi
310313
elif [ "$OPTION" == "Enable (Default)" ] || [ "${OPTION,,}" == "enable" ]; then
311-
if [ -f "/etc/wireplumber/wireplumber.conf.d/51-disable-bluetooth-headphone-profile-switch.conf" ]; then
312-
sudo rm "/etc/wireplumber/wireplumber.conf.d/51-disable-bluetooth-headphone-profile-switch.conf"
314+
if [ $(find "${WIREPLUMBER_DIR}" -type f | wc -l) -eq 1 ] && [ -f "${WIREPLUMBER_DIR}/${WIREPLUMBER_FILE}" ]; then
315+
sudo rm -r "${WIREPLUMBER_DIR}
316+
else
317+
sudo rm "${WIREPLUMBER_DIR}/${WIREPLUMBER_FILE}"
318+
fi
313319
systemctl --user restart wireplumber
314320
echo 'Reverted setting "Bluetooth headset profile" to defaults.'
315321
else

0 commit comments

Comments
 (0)