added argument remote script

This commit is contained in:
Shihaam Abdul Rahman 2024-09-17 14:47:37 +05:00
parent bc7cdff069
commit b4de80fb72
Signed by: shihaam
GPG Key ID: 6DA2E87EBC227636
2 changed files with 138 additions and 0 deletions

138
remote-arg Executable file
View File

@ -0,0 +1,138 @@
#!/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
sleep 0.5
}
tap() {
$ADB input tap $1 $2
}
open_menu() {
tap 50 50
}
select_device() {
case "$1" in
fan)
connect_device
launch_app
tap 60 200
sleep 0.6
;;
ac)
connect_device
launch_app
tap 60 300
sleep 0.6
;;
*)
echo "Invalid device. Use: fan or ac"
usage
;;
esac
}
control_fan() {
case "$1" in
power)
tap 100 250
;;
swing)
tap 950 260
;;
speed)
tap 540 1200
;;
mode)
tap 540 1400
;;
*)
echo "Invalid fan command. Use: power, swing, speed, or mode"
exit 1
;;
esac
}
control_ac() {
case "$1" in
power)
tap 170 400
;;
mode)
tap 950 400
;;
speed)
tap 170 1200
;;
temp)
case "$2" in
-)
tap 360 1053
;;
+)
tap 710 1053
;;
*)
echo "Invalid temperature command. Use: + or -"
exit 1
;;
esac
;;
*)
echo "Invalid AC command. Use: power, mode, speed, or temp"
exit 1
;;
esac
}
usage() {
echo "Usage: $0 <device> <command> [option]"
echo "Devices: fan, ac"
echo "Fan commands: power, swing, speed, mode"
echo "AC commands: power, mode, speed, temp"
echo "Temperature options: +, -"
echo "Examples:"
echo " $0 fan power"
echo " $0 ac temp -"
exit 1
}
# Main script
if [ $# -lt 2 ]; then
usage
fi
device=$1
command=$2
option=$3
select_device $device
case $device in
fan)
control_fan $command
;;
ac)
control_ac $command $option
;;
*)
echo "Invalid device. Use: fan or ac"
exit 1
;;
esac
echo "Command executed successfully"

View File