tools/nav-mode (2229 bytes)
1 #!/usr/bin/env bash 2 # Switches the reader's system navigation: the three-button bar and the swipe 3 # gestures. Android lets no app do this, so it is done over adb, once; it 4 # survives restarts. Power key combinations are set inside AssistKey instead. 5 # 6 # tools/nav-mode buttons nogestures three-button bar, no gestures at all 7 # tools/nav-mode nobuttons gestures gestures only 8 # tools/nav-mode nobuttons nogestures neither: Power key combinations only 9 # tools/nav-mode buttons gestures both 10 # tools/nav-mode status 11 # 12 # Order matters: switching the overlay makes SystemUI forget 13 # disable_gesture_bottom, so the overlay goes first and the setting after. 14 set -euo pipefail 15 export MSYS_NO_PATHCONV=1 16 OVERLAY=com.android.internal.systemui.navbar 17 18 status() { 19 local mode gest 20 mode=$(adb shell settings get secure navigation_mode | tr -d '\r') 21 gest=$(adb shell settings get system disable_gesture_bottom | tr -d '\r') 22 echo "button bar: $([ "$mode" = "2" ] && echo hidden || echo showing)" 23 echo "swipe-up gesture: $([ "$gest" = "1" ] && echo off || echo on)" 24 echo "edge-swipe back: $([ "$mode" = "2" ] && echo "inset scale $(adb shell settings get secure back_gesture_inset_scale_left | tr -d '\r')" || echo "n/a with the bar")" 25 } 26 27 [ "${1:-}" = "status" ] && { status; exit 0; } 28 [ $# -eq 2 ] || { sed -n '2,14p' "$0"; exit 2; } 29 30 case "$1" in buttons) cat=threebutton;; nobuttons) cat=gestural;; *) echo "first argument: buttons | nobuttons"; exit 2;; esac 31 case "$2" in gestures) off=0; scale=0.6;; nogestures) off=1; scale=0;; *) echo "second argument: gestures | nogestures"; exit 2;; esac 32 33 if [ "$cat" = gestural ] && [ "$off" = 1 ]; then 34 echo "No bar and no gestures: make sure AssistKey's Power key combinations work first." 35 echo "To undo from a computer: tools/nav-mode buttons gestures" 36 fi 37 38 adb shell cmd overlay enable-exclusive --category "$OVERLAY.$cat" 39 sleep 5 40 adb shell settings put system disable_gesture_bottom $((1 - off)) # nudge the observer 41 sleep 1 42 adb shell settings put system disable_gesture_bottom "$off" 43 adb shell settings put secure back_gesture_inset_scale_left "$scale" 44 adb shell settings put secure back_gesture_inset_scale_right "$scale" 45 sleep 1 46 status