Skip to content

Instantly share code, notes, and snippets.

@gustavomdsantos
Last active November 3, 2021 21:57
Show Gist options
  • Save gustavomdsantos/0e076c60a58a1ae1f233ab0f270931d0 to your computer and use it in GitHub Desktop.
Save gustavomdsantos/0e076c60a58a1ae1f233ab0f270931d0 to your computer and use it in GitHub Desktop.
ScrCpy Launcher - Bash script for rom1v's application.
#!/usr/bin/env bash
windowTitle="ScrCpy Launcher, by rom1v and gustavomdsantos"
bold=$(tput bold)
normal=$(tput sgr0)
splashText="
${bold}rom1v${normal} and ${bold}gustavomdsantos${normal} presents:
███████ ██████ ██████ ██████ ██████ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ██
███████ ██ ██████ ██ ██████ ████
██ ██ ██ ██ ██ ██ ██
███████ ██████ ██ ██ ██████ ██ ██
| Shortcuts | Action |
|-------------| ---------------------------|
| \`Alt\` + \`B\` | ◀ ('Back' button) |
| \`Alt\` + \`H\` | ⬤ ('Home' button) |
| \`Alt\` + \`S\` | ■ ('App Switch' button) |
| \`Alt\` + \`M\` | ☰ ('Menu' button) |
| \`Alt\` + \`F\` | ⛶ (Switch Fullscreen mode) |
"
detectOS() {
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) machine=Unix;;
Darwin*) machine=Unix;;
CYGWIN*) machine=Windows;;
MINGW*) machine=Windows;;
*) machine="UNKNOWN:${unameOut}"
esac
echo ${machine}
}
runScrCpy() {
osDetected=$(detectOS);
if [[ "$osDetected" == "Windows" ]]
then
deviceModel=$(./adb devices -l | cut -d' ' -f18 | cut -d':' -f2)
./scrcpy.exe --max-size 720 --window-height 720 --max-fps 30 -b 5000000 --window-title "ScrCpy - $deviceModel"
elif [[ "$osDetected" == "Unix" ]]
then
deviceModel=$(adb devices -l | cut -d' ' -f18 | cut -d':' -f2)
scrcpy --max-size 720 --window-height 720 --max-fps 30 -b 5000000 --window-title "ScrCpy - $deviceModel"
else
echo "ERROR: UNKNOWN OS DETECTED! WE COULDN'T RUN SCRCPY!"
fi
}
echo -ne "\e]0;$windowTitle\a"
echo "$splashText"
runScrCpy
echo -e "\nClosing automatically in 5 seconds..."
sleep 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment