You can create a bash script that checks the power status of the bluetooth adapter, ensures devices are paired, and sets the discoverable timeout. Then, you can set up a cron job that runs the script every minute. 1. Create a bash script `bluetooth_check.sh`. Open a text editor like nano: ```bash nano bluetooth_check.sh ``` 2. In `bluetooth_check.sh`, enter the following: ```bash #!/bin/bash # Devices' MAC addresses DEVICE1="DC:1A:60:35:8D:D2" DEVICE2="DD:14:3E:E7:6E:9B" # Check power status and turn power on if necessary POWER_STATUS=$(echo -e 'show' | bluetoothctl | grep "Powered: yes" | cut -d ' ' -f2- | tr -d '\n') if [ "$POWER_STATUS" != "yes" ]; then echo -e 'power on' | bluetoothctl fi # Check if devices are paired and pair if necessary for DEVICE in $DEVICE1 $DEVICE2; do IS_PAIRED=$(echo -e 'paired-devices' | bluetoothctl | grep $DEVICE | wc -l) if [ $IS_PARED -eq 0 ]; then echo -e 'pair $DEVICE\nyes\nquit' | bluetoothctl fi done # Set discoverable timeout echo -e 'discoverable-timeout -1' | bluetoothctl ``` 3. Save and exit the text editor. Make the script executable with the following command: ```bash chmod +x bluetooth_check.sh ``` 4. Open the crontab file: ```bash crontab -e ``` 5. Add the following line to the crontab file: ```bash * * * * * /path/to/bluetooth_check.sh >/dev/null 2>&1 ``` Replace `/path/to/` with the actual path to the `bluetooth_check.sh` script. 6. Save and exit the crontab file. The cron job is now set to run every minute. This script doesn't handle cases where Bluetooth might need a PIN to pair. It simply tries to pair the devices if they're not already paired. If your devices require a PIN, you might need to pair them manually the first time, and then the script will keep them paired. This script also assumes that the Bluetooth service is running. If the service isn't running, you might need to start it manually with `sudo service bluetooth start` or configure it to start automatically on boot with `sudo systemctl enable bluetooth.service`.