First version -- working.
This commit is contained in:
38
off.sh
Normal file
38
off.sh
Normal file
@ -0,0 +1,38 @@
|
||||
TIME_START=00:00
|
||||
TIME_STOP=23:59
|
||||
|
||||
tv_check()
|
||||
{
|
||||
ping -c 1 -W 1 192.168.1.12 2>&1 > /dev/null || { echo "TV is unreachable."; return; }
|
||||
adb connect 192.168.1.12
|
||||
|
||||
if adb shell dumpsys power | grep mWakefulness=Awake
|
||||
then
|
||||
adb shell input keyevent 26
|
||||
else
|
||||
echo "TV is turning OFF."
|
||||
fi
|
||||
}
|
||||
|
||||
gabi_check()
|
||||
{
|
||||
loginctl list-users | grep gabi || { echo 'Gabi is not online.'; return; }
|
||||
doas loginctl terminate-user gabi
|
||||
}
|
||||
|
||||
S=$(date -d "$TIME_START" +%s)
|
||||
T=$(date -d "$TIME_STOP" +%s)
|
||||
C=$(date +%s)
|
||||
if [ $C -lt $S ]
|
||||
then
|
||||
echo "PRE: $((S - C)) seconds to go."
|
||||
elif [ $C -gt $T ]
|
||||
then
|
||||
echo "POST: $((C - T)) seconds passed."
|
||||
else
|
||||
echo "ACTIVE: Executing for the next $((T - C)) seconds."
|
||||
gabi_check
|
||||
tv_check
|
||||
fi
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user