From 0c91689f9e28069e5a2245fd4d55082b5720f6bf Mon Sep 17 00:00:00 2001 From: Shihaam Abdul Rahman Date: Mon, 16 Sep 2024 23:56:03 +0500 Subject: [PATCH] init - fan on/off works --- remote | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100755 remote diff --git a/remote b/remote new file mode 100755 index 0000000..fd7144d --- /dev/null +++ b/remote @@ -0,0 +1,77 @@ +#!/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.5 +} + +tap() { + $ADB input tap $1 $2 + sleep 1.5 +} + +open_menu() { + tap 10 50 # Adjust these coordinates for the menu button +} + +select_device() { + case "$1" in + fan) + tap 20 150 # Adjust these coordinates for the fan option + ;; + ac) + tap 20 250 # Adjust these coordinates for the AC option + ;; + *) + echo "Unknown device: $1" + exit 1 + ;; + esac +} + +control_device() { + case "$1" in + power) + tap 30 200 # Adjust for power button + ;; + speed) + tap 30 300 # Adjust for speed button + ;; + mode) + tap 30 400 # Adjust for mode button + ;; + *) + echo "Unknown command: $1" + exit 1 + ;; + esac +} + +# Main script +connect_device +launch_app + +# Check if enough arguments are provided +if [ "$#" -lt 2 ]; then + echo "Usage: $0 {fan|ac} {power|speed|mode}" + exit 1 +fi + +# Select device +open_menu +select_device "$1" + +# Control device +control_device "$2" + +echo "Command executed successfully"