138 lines
3.3 KiB
Bash
Executable File

#!/bin/bash
DEVICE="10.0.1.170:5555"
ADB="adb -s $DEVICE shell"
connect_device() {
if ! adb connect 10.0.1.170; then
echo "Failed to connect to device"
exit 1
fi
}
launch_app() {
$ADB monkey -p com.tiqiaa.remote -c android.intent.category.LAUNCHER 1 > /dev/null 2>&1
sleep 1.3
open_menu # open menu
sleep 1
open_menu # close menu.... the button is same place
### Inital Menu animation is slow, so opening and closing menu after opening app fixes it
## and then next time menu is fast, so its faster to switch device by doing this
}
tap() {
$ADB input tap $1 $2
}
open_menu() {
tap 50 50 # Adjust these coordinates for the menu button
}
select_device() {
case "$1" in
fan)
open_menu
sleep 0.6 # wait for menu to settle
tap 60 200 # Select Fan from the list
sleep 0.4 # wait for menu to disappear
;;
ac)
open_menu
sleep 0.6 # wait for menu to settle
tap 60 300 # Select AC from the list
sleep 0.4 # Wait for menu to disappear
;;
esac
}
show_main_menu() {
clear
echo "==== Remote Control Menu ===="
echo "1. Control Fan"
echo "2. Control AC"
echo "x. Exit"
echo "============================"
read -n 1 -p "Enter your choice: " choice
case $choice in
1) select_device fan # Select Fan
fan_menu "Fan"
;;
2) select_device ac
ac_menu "AC"
;;
x|X) exit 0
;;
*) echo ""
echo "Invalid choice. Try Again..."
sleep 0.5
show_main_menu ;;
esac
}
fan_menu() {
clear
echo "==== Fan Control Menu ===="
echo "1. Power On/Off"
echo "2. Swing On/Off"
echo "3. Speed"
echo "4. Wind Type"
echo "x. Main Menu"
echo "============================="
read -n 1 -p "Enter your choice: " choice
case $choice in
1) tap 100 250 # Fan On/Off button
fan_menu ;;
2) tap 950 260 ## Occilation On/Off Button
fan_menu ;;
3) tap 540 1200 ## Fan Speed button
fan_menu ;;
4) tap 540 1400 ## Fan Mode button
fan_menu ;;
x|X) show_main_menu ;;
*) echo ""
echo "Invalid choice. Try Again..."
sleep 0.5
fan_menu ;;
esac
}
ac_menu() {
clear
echo "==== AC Control Menu ===="
echo "1. Power On/Off"
echo "2. Mode"
echo "3. Fan Speed"
echo "-. Temp -"
echo "+. Temp +"
echo "x. Main Menu"
echo "============================="
read -n 1 -p "Enter your choice: " choice
case $choice in
1) tap 170 400 ## AC On/Off button
ac_menu ;;
2) tap 950 400 ## AC Mode Button
ac_menu ;;
3) tap 170 1200 ## AC Fan Speed
ac_menu ;;
-|_) tap 360 1053 ## temp - button
ac_menu ;;
+|=) tap 710 1053 ## temp + button
ac_menu ;;
x|X) show_main_menu ;;
*) echo ""
echo "Invalid choice. Try Again..."
sleep 0.5; ac_menu ;;
esac
}
# Main script
connect_device
launch_app
# Start the main menu loop
while true; do
show_main_menu
done