Skip to content

Instantly share code, notes, and snippets.

@dipendra-sharma
Created April 1, 2026 12:24
Show Gist options
  • Select an option

  • Save dipendra-sharma/db69349ea18720ccf4379ac955a75ec9 to your computer and use it in GitHub Desktop.

Select an option

Save dipendra-sharma/db69349ea18720ccf4379ac955a75ec9 to your computer and use it in GitHub Desktop.
Switch Android navigation mode (3-button / 2-button / gesture) via ADB overlay commands — works on Xiaomi and other OEM devices
#!/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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment