Skip to content

Instantly share code, notes, and snippets.

@Shukuyen
Last active September 16, 2022 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shukuyen/c80a9d638e35a8744cdaa7e798077260 to your computer and use it in GitHub Desktop.
Save Shukuyen/c80a9d638e35a8744cdaa7e798077260 to your computer and use it in GitHub Desktop.
Shell script to clean up Android status bar for screenshots or screen recordings
#! /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
@Shukuyen
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment