mirror of
https://github.com/tw93/Mole.git
synced 2026-03-22 20:15:07 +00:00
fix(optimize): warn before bluetooth refresh
Show "Bluetooth devices may disconnect briefly during refresh" before actually restarting bluetoothd, so the user is not surprised by a momentary disconnect.
This commit is contained in:
@@ -641,6 +641,7 @@ opt_bluetooth_reset() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
local spinner_started="false"
|
local spinner_started="false"
|
||||||
|
local disconnect_notice="Bluetooth devices may disconnect briefly during refresh"
|
||||||
if [[ -t 1 ]]; then
|
if [[ -t 1 ]]; then
|
||||||
MOLE_SPINNER_PREFIX=" " start_inline_spinner "Checking Bluetooth..."
|
MOLE_SPINNER_PREFIX=" " start_inline_spinner "Checking Bluetooth..."
|
||||||
spinner_started="true"
|
spinner_started="true"
|
||||||
@@ -688,6 +689,7 @@ opt_bluetooth_reset() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if sudo pkill -TERM bluetoothd > /dev/null 2>&1; then
|
if sudo pkill -TERM bluetoothd > /dev/null 2>&1; then
|
||||||
|
echo -e " ${GRAY}${ICON_WARNING}${NC} ${GRAY}${disconnect_notice}${NC}"
|
||||||
sleep 1
|
sleep 1
|
||||||
if pgrep -x bluetoothd > /dev/null 2>&1; then
|
if pgrep -x bluetoothd > /dev/null 2>&1; then
|
||||||
sudo pkill -KILL bluetoothd > /dev/null 2>&1 || true
|
sudo pkill -KILL bluetoothd > /dev/null 2>&1 || true
|
||||||
@@ -707,6 +709,7 @@ opt_bluetooth_reset() {
|
|||||||
if [[ "$spinner_started" == "true" ]]; then
|
if [[ "$spinner_started" == "true" ]]; then
|
||||||
stop_inline_spinner
|
stop_inline_spinner
|
||||||
fi
|
fi
|
||||||
|
echo -e " ${YELLOW}${ICON_DRY_RUN}${NC} ${disconnect_notice}"
|
||||||
opt_msg "Bluetooth module restarted"
|
opt_msg "Bluetooth module restarted"
|
||||||
opt_msg "Connectivity issues resolved"
|
opt_msg "Connectivity issues resolved"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -1520,6 +1520,7 @@ opt_bluetooth_reset
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
|
[[ "$output" == *"Bluetooth devices may disconnect briefly during refresh"* ]]
|
||||||
[[ "$output" == *"Bluetooth module restarted"* ]]
|
[[ "$output" == *"Bluetooth module restarted"* ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user