Skip to content

Commit

Permalink
👌 IMPROVE: New releases. Refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcerrejon committed Feb 22, 2021
1 parent c2185af commit c53b221
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 37 deletions.
30 changes: 5 additions & 25 deletions scripts/others/rpiplay.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Description : RPiPlay - Airplay mirroring
# Author : Jose Cerrejon Gonzalez (ulysess@gmail_dot._com)
# Version : 1.1.0 (03/Jan/21)
# Version : 1.1.1 (22/Feb/21)
#
. ./scripts/helper.sh || . ../helper.sh || . ./helper.sh || wget -q 'https://github.com/jmcerrejon/PiKISS/raw/master/scripts/helper.sh'
clear
Expand Down Expand Up @@ -83,20 +83,18 @@ end_message() {
compile() {
echo -e "\nInstalling dependencies (if proceed)...\n"
install_packages_if_missing "${PACKAGES_DEV[@]}"
sudo apt install -y
cd "$INSTALL_DIR" || exit 1
mkdir -p ~/sc && cd "$_" || exit 1
git clone "$SOURCE_CODE_URL" rpiplay && cd "$_" || exit 1
mkdir build && cd "$_" || exit 1
cmake --DCMAKE_CXX_FLAGS="-O3" --DCMAKE_C_FLAGS="-O3" ..
echo -e "\n\nCompiling...\n"
echo -e "\nCompiling at ~/sc/rpiplay, please wait..."
make_with_all_cores
mv rpiplay ../rpiplay
end_message
runme
}

install() {
install_script_message
echo -e "\nInstalling dependencies (if proceed)...\n"
install_packages_if_missing "${PACKAGES[@]}"
download_binaries
Expand All @@ -106,23 +104,5 @@ install() {
runme
}

menu() {
while true; do
dialog --clear \
--title "[ RPiPlay ]" \
--menu "Select from the list:" 11 68 3 \
INSTALL "Binary (Recommended)" \
COMPILE "Latest from source code. Estimated time on RPi 4: ~3 minutes." \
Exit "Exit" 2>"${INPUT}"

menuitem=$(<"${INPUT}")

case $menuitem in
INSTALL) clear && install ;;
COMPILE) clear && compile ;;
Exit) exit ;;
esac
done
}

menu
install_script_message
install
52 changes: 40 additions & 12 deletions scripts/others/scrcpy.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
#!/bin/bash
#
# Description : scrcpy thks to Pi Labs
# Description : scrcpy
# Author : Jose Cerrejon Gonzalez (ulysess@gmail_dot._com)
# Version : 1.0.2 (03/Jan/21)
# Version : 1.1.0 (22/Feb/21)
#
. ./scripts/helper.sh || . ../helper.sh || . ./helper.sh || wget -q 'https://github.com/jmcerrejon/PiKISS/raw/master/scripts/helper.sh'
clear
check_board || { echo "Missing file helper.sh. I've tried to download it for you. Try to run the script again." && exit 1; }

readonly INSTALL_DIR="$HOME"
readonly INSTALL_DIR="$HOME/apps"
readonly PACKAGES=(adb ffmpeg libsdl2-2.0-0)
readonly BINARY_PATH="https://misapuntesde.com/rpi_share/scrcpy-1.13.tar.gz"
readonly PACKAGES_DEV=(ffmpeg libsdl2-2.0-0 adb pkg-config ninja-build libavcodec-dev libavformat-dev libavutil-dev libsdl2-dev)
readonly BINARY_URL="https://misapuntesde.com/rpi_share/scrcpy-1.17.tar.gz"
readonly PREBUILD_SERVER_URL="https://github.com/Genymobile/scrcpy/releases/download/v1.17/scrcpy-server-v1.17"
readonly SOURCE_CODE_URL="https://github.com/Genymobile/scrcpy"

remove_files() {
sudo rm -rf "$INSTALL_DIR"/scrcpy /usr/local/share/scrcpy ~/.local/share/applications/scrcpy.desktop
sudo rm -rf "$INSTALL_DIR"/scrcpy /usr/local/share/scrcpy ~/.local/share/applications/scrcpy.desktop /usr/local/share/scrcpy/scrcpy-server
}

uninstall() {
Expand Down Expand Up @@ -42,25 +44,51 @@ generate_icon() {
cat <<EOF >~/.local/share/applications/scrcpy.desktop
[Desktop Entry]
Name=Scrcpy
Exec=${PWD}/scrcpy/android.sh
Icon=${PWD}/scrcpy/android.jpg
Path=${PWD}/scrcpy/
Exec=${INSTALL_DIR}/scrcpy/android.sh
Icon=${INSTALL_DIR}/scrcpy/android.jpg
Path=${INSTALL_DIR}/scrcpy/
Type=Application
Terminal=true
X-KeepTerminal=true
Comment=Display and control of Android devices connected on USB
Categories=ConsoleOnly;Utility;System;
EOF
fi
}

download_prebuild_server() {
echo -e "\nDownloading prebuild server..."
[[ -e ~/sc/scrcpy ]] && cd ~/sc/scrcpy || exit 1
wget -q -c "$PREBUILD_SERVER_URL"
}

compile() {
echo -e "\nInstalling dependencies (if proceed)..."
install_packages_if_missing "${PACKAGES_DEV[@]}"
install_meson
mkdir -p ~/sc && cd "$_" || exit 1
git clone "$SOURCE_CODE_URL" scrcpy && cd "$_" || exit 1
download_prebuild_server
meson build --buildtype release --strip -Db_lto=true -Dprebuilt_server=scrcpy-server-v1.17
ninja -Cbuild
if [[ ! -e ~/sc/scrcpy/build/app/scrcpy ]]; then
echo -e "\nSomething is wrong :("
exit_message
fi
echo -e "\nDone!. Check ~/sc/scrcpy/build/app"
exit_message
}

install() {
echo -e "\nInstalling dependencies (if proceed)...\n"
install_packages_if_missing "${PACKAGES[@]}"
echo -e "\nInstalling binary files..."
download_and_extract "$BINARY_PATH" "$INSTALL_DIR"
download_and_extract "$BINARY_URL" "$INSTALL_DIR"
sudo mkdir -p /usr/local/share/scrcpy
sudo cp -f "$HOME/scrcpy/scrcpy-server" /usr/local/share/scrcpy/scrcpy-server
# TODO I think the next file is not neccessary. Remove if nobody has issues not including this
# sudo cp -f "$INSTALL_DIR/scrcpy/scrcpy-server" /usr/local/share/scrcpy/scrcpy-server
generate_icon
echo -e "\nDone. Type $INSTALL_DIR/scrcpy/android.sh or go to Menu > System Tools > Scrcpy.\n"
echo -e "\nDone. Type $INSTALL_DIR/scrcpy/android.sh or go to Menu > System Tools > Scrcpy."
exit_message
}

Expand All @@ -71,7 +99,7 @@ Install Scrcpy
· More info scrcpy --help or visiting $SOURCE_CODE_URL
· The Android device requires at least API 21 (Android 5.0).
· Make sure you enabled adb debugging on your device(s).
· Make sure you enabled adb debugging on your device(s) and plug an Android device before start scrcpy.
· On some devices, you also need to enable an additional option to control it using keyboard and mouse.
· If you have issues, try to run the app a couple of times through Terminal.
Expand Down

0 comments on commit c53b221

Please sign in to comment.