mirror of
https://github.com/palera1n/palera1n.git
synced 2026-10-23 18:49:48 +02:00
Fix dfuhelper slowness (mainly on macOS) (#351)
system_profiler takes ~0.2s on my MacBook Air M1 and it was being called twice per second. I made it so it's only called once per second and also put the whole check on a background thread to ensure the countdown doesn't get slowed down.
This commit is contained in:
1 parent
315de66663
commit
28c6fb02d8
1 file changed
+9
-3
+9
-3
@@ -41,10 +41,15 @@ remote_cp() {
|
||||
}
|
||||
|
||||
step() {
|
||||
rm -f .entered_dfu
|
||||
for i in $(seq "$1" -1 0); do
|
||||
if [[ $(get_device_mode) == "dfu" || ($1 == "10" && $(get_device_mode) != "none") ]]; then
|
||||
if [[ -e .entered_dfu ]]; then
|
||||
rm -f .entered_dfu
|
||||
break
|
||||
fi
|
||||
if [[ $(get_device_mode) == "dfu" || ($1 == "10" && $(get_device_mode) != "none") ]]; then
|
||||
touch .entered_dfu
|
||||
fi &
|
||||
printf '\r\e[K\e[1;36m%s (%d)' "$2" "$i"
|
||||
sleep 1
|
||||
done
|
||||
@@ -200,7 +205,8 @@ _reset() {
|
||||
|
||||
get_device_mode() {
|
||||
if [ "$os" = "Darwin" ]; then
|
||||
apples="$(system_profiler SPUSBDataType 2> /dev/null | grep -B1 'Vendor ID: 0x05ac' | grep 'Product ID:' | cut -dx -f2 | cut -d' ' -f1 | tail -r)"
|
||||
sp="$(system_profiler SPUSBDataType 2> /dev/null)"
|
||||
apples="$(printf '%s' "$sp" | grep -B1 'Vendor ID: 0x05ac' | grep 'Product ID:' | cut -dx -f2 | cut -d' ' -f1 | tail -r)"
|
||||
elif [ "$os" = "Linux" ]; then
|
||||
apples="$(lsusb | cut -d' ' -f6 | grep '05ac:' | cut -d: -f2)"
|
||||
fi
|
||||
@@ -244,7 +250,7 @@ get_device_mode() {
|
||||
if [ "$os" = "Linux" ]; then
|
||||
usbserials=$(cat /sys/bus/usb/devices/*/serial)
|
||||
elif [ "$os" = "Darwin" ]; then
|
||||
usbserials=$(system_profiler SPUSBDataType 2> /dev/null | grep 'Serial Number' | cut -d: -f2- | sed 's/ //')
|
||||
usbserials=$(printf '%s' "$sp" | grep 'Serial Number' | cut -d: -f2- | sed 's/ //')
|
||||
fi
|
||||
if grep -qE '(ramdisk tool|SSHRD_Script) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) [0-9]{1,2} [0-9]{4} [0-9]{2}:[0-9]{2}:[0-9]{2}' <<< "$usbserials"; then
|
||||
device_mode=ramdisk
|
||||
|
||||
Reference in new issue
Block a user