Shell script to clean up Android status bar for screenshots or screen recordings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
DEVICES=$(adb devices | wc -l) | |
if [ $DEVICES -le 2 ] | |
then | |
echo "No devices connected via adb." | |
exit 1 | |
fi | |
if [ "$#" -lt 1 ] || ([ "$1" != "on" ] && [ "$1" != "off" ]); | |
then | |
echo "Usage: cleandroid on|off 1200 [clock to set in hhmm, optional]" | |
exit 1 | |
fi | |
case $1 in | |
"on") | |
echo "Cleaning Android UI." | |
adb shell settings put global sysui_demo_allowed 1 | |
if [ "$#" -eq 2 ] && [[ $2 =~ ^[0-9]{4}$ ]]; | |
then | |
adb shell am broadcast -a com.android.systemui.demo -e command clock -e hhmm $2 &> /dev/null | |
fi | |
{ | |
adb shell am broadcast -a com.android.systemui.demo -e command network -e mobile show -e level 4 -e datatype false | |
adb shell am broadcast -a com.android.systemui.demo -e command notifications -e visible false | |
adb shell am broadcast -a com.android.systemui.demo -e command battery -e plugged false -e level 100 | |
} &> /dev/null | |
;; | |
"off") | |
echo "Restoring Android UI." | |
adb shell am broadcast -a com.android.systemui.demo -e command exit &> /dev/null | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Based on https://medium.com/android-news/clean-your-status-bar-like-a-pro-76c89a1e2c2f