Skip to content

Instantly share code, notes, and snippets.

View joshespi's full-sized avatar

Josh Espinoza joshespi

View GitHub Profile
@joshespi
joshespi / check_turnoffTV.sh
Last active December 11, 2023 21:29
Checks power status of device 0 then turns it off if the device is on
#!/bin/bash
# Get the current hour in local time
current_hour_local=$(date +%H)
# Check if the current time is before 7 AM or after 5 PM
if [ "$current_hour_local" -lt 7 ] || [ "$current_hour_local" -ge 17 ]; then
# Run cec-client and capture the power status of the TV
power_status=$(echo 'pow 0' | cec-client -s -d 1 | grep 'power status' | awk '{print $3}')