|
#!/bin/bash |
|
# Switch Android navigation mode on Xiaomi (and other overlay-based devices) |
|
# Usage: ./scripts/nav_mode.sh [0|1|2] |
|
# 0 = 3-button navigation (back / home / recents) |
|
# 1 = 2-button navigation (back + pill) |
|
# 2 = gesture navigation (pill only, swipe-based) |
|
|
|
MODE=${1:-""} |
|
|
|
usage() { |
|
echo "Usage: $0 [0|1|2]" |
|
echo " 0 = 3-button navigation" |
|
echo " 1 = 2-button navigation" |
|
echo " 2 = gesture navigation" |
|
echo "" |
|
echo "Current mode: $(adb shell settings get secure navigation_mode 2>/dev/null)" |
|
echo "Active overlay:" |
|
adb shell cmd overlay list 2>/dev/null | grep -E "^\[x\].*navbar" |
|
} |
|
|
|
if [[ -z "$MODE" ]]; then |
|
usage |
|
exit 0 |
|
fi |
|
|
|
case "$MODE" in |
|
0) |
|
echo "→ Switching to 3-button navigation..." |
|
adb shell cmd overlay enable com.android.internal.systemui.navbar.threebutton |
|
adb shell cmd overlay disable com.android.internal.systemui.navbar.twobutton |
|
adb shell cmd overlay disable com.android.internal.systemui.navbar.gestural |
|
adb shell cmd overlay disable com.android.internal.systemui.navbar.gestural_wide_back |
|
adb shell cmd overlay disable com.android.internal.systemui.navbar.gestural_extra_wide_back |
|
adb shell cmd overlay disable com.android.internal.systemui.navbar.gestural_narrow_back |
|
adb shell settings put secure navigation_mode 0 |
|
;; |
|
1) |
|
echo "→ Switching to 2-button navigation..." |
|
adb shell cmd overlay enable com.android.internal.systemui.navbar.twobutton |
|
adb shell cmd overlay disable com.android.internal.systemui.navbar.threebutton |
|
adb shell cmd overlay disable com.android.internal.systemui.navbar.gestural |
|
adb shell cmd overlay disable com.android.internal.systemui.navbar.gestural_wide_back |
|
adb shell cmd overlay disable com.android.internal.systemui.navbar.gestural_extra_wide_back |
|
adb shell cmd overlay disable com.android.internal.systemui.navbar.gestural_narrow_back |
|
adb shell settings put secure navigation_mode 1 |
|
;; |
|
2) |
|
echo "→ Switching to gesture navigation..." |
|
adb shell cmd overlay enable com.android.internal.systemui.navbar.gestural |
|
adb shell cmd overlay disable com.android.internal.systemui.navbar.threebutton |
|
adb shell cmd overlay disable com.android.internal.systemui.navbar.twobutton |
|
adb shell settings put secure navigation_mode 2 |
|
;; |
|
*) |
|
echo "Error: invalid mode '$MODE'" |
|
usage |
|
exit 1 |
|
;; |
|
esac |
|
|
|
echo "Done. Hot restart your app (press R in the Flutter terminal)." |
|
echo "Active overlay:" |
|
adb shell cmd overlay list 2>/dev/null | grep -E "^\[x\].*navbar" |