device switch stores state

This commit is contained in:
Shihaam Abdul Rahman 2024-09-17 00:16:43 +05:00
parent 0c91689f9e
commit efc2dd5d61
Signed by: shihaam
GPG Key ID: 6DA2E87EBC227636

88
remote
View File

@ -26,52 +26,76 @@ open_menu() {
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
;;
1) tap 20 150 ;; # Fan
2) tap 20 250 ;; # AC
esac
}
control_device() {
case "$1" in
power)
tap 30 200 # Adjust for power button
1) tap 30 200 ;; # Power
2) tap 30 300 ;; # Speed
3) tap 30 400 ;; # Mode
esac
}
show_main_menu() {
clear
echo "==== Remote Control Menu ===="
echo "1. Control Fan"
echo "2. Control AC"
echo "3. Exit"
echo "============================"
read -p "Enter your choice: " choice
case $choice in
1)
open_menu
tap 20 150 # Select Fan
# sleep 1.5 # Wait for menu to settle
device_menu "Fan"
;;
speed)
tap 30 300 # Adjust for speed button
2)
open_menu
tap 20 250 # Select AC (adjust coordinates as needed)
# sleep 1.5 # Wait for menu to settle
device_menu "AC"
;;
mode)
tap 30 400 # Adjust for mode button
3)
exit 0
;;
*)
echo "Unknown command: $1"
exit 1
echo "Invalid choice. Press Enter to continue..."
read
show_main_menu
;;
esac
}
device_menu() {
local device=$1
clear
echo "==== $device Control Menu ===="
echo "1. Power On/Off"
echo "2. Change Speed"
echo "3. Change Mode"
echo "4. Back to Main Menu"
echo "============================="
read -p "Enter your choice: " choice
case $choice in
1) tap 30 200 ;;
2) echo wip ;;
3) echo wip ;;
4) show_main_menu ;;
*) echo "Invalid choice. Press Enter to continue..."; read; device_menu "$device" ;;
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"
# Start the main menu loop
while true; do
show_main_menu
done