137 lines
3.0 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.4
tap 60 200
;; # Fan from the list
ac)
open_menu
sleep 0.4
tap 60 300
;; # AC from the list
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
sleep 0.5
fan_menu "Fan"
;;
2)
select_device ac # Select AC (adjust coordinates as needed)
sleep 0.5
ac_menu "AC"
;;
x|X)
exit 0
;;
*)
echo "Invalid choice. Press Enter to continue..."
read
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_menu ;;
2) tap 950 260
fan_menu ;;
3) tap 540 1200
fan_menu ;;
4) tap 540 1400
fan_menu ;;
x|X) show_main_menu ;;
*) 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 ## Fan Speed
ac_menu ;;
-|_) tap 360 1053 ## temp - button
ac_menu ;;
+|=) tap 710 1053 ## temp + button
ac_menu ;;
x|X) show_main_menu ;;
*) 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