from datetime import datetime
from  pygame import mixer
from time import time

def music_on_loop(file,stopper):
    mixer.init()
    mixer.music.load(file)
    mixer.music.play()
    while True:
        a=input()
        if a==stopper:
            mixer.music.stop()
            break


def log_now(msg):
    with open("my_logs.txt","a")as f:
        f.write(f"{msg} {datetime.now()}\n")

if __name__=='__main__':
    # music_on_loop("chunari.mp3","stop")
    init_water= time()
    init_eyes= time()
    init_exercise= time()

    watersecs=40*60
    eyessecs=30*60
    exsecs =45*60

    while True:
        if time() - init_water > watersecs:
            print("water drinking time bro!!!  Enter 'drank ' to  stop the alarm .")
            music_on_loop('pani.mp3', 'drank')
            init_water = time()
            log_now("Drank water at ")

        if time() - init_eyes > eyessecs:
            print("Eye exercisng time  bro!!!  Enter 'eye done ' to  stop the alarm .")
            music_on_loop('pani.mp3', 'eye done')
            init_eyes = time()
            log_now("Eyes Exercising done at  ")

        if time() - init_exercise > exsecs:
            print("physical exercise time bro!!!  Enter 'exercise done  ' to  stop the alarm .")
            music_on_loop('pani.mp3', 'exercise done ')
            init_exercise = time()
            log_now("Physical Exercise done at ")






#Healthy Programmer
# 9am - 5pm
# Water - water.mp3 (3.5 litres) - Drank - log - Every 40 min
# Eyes - eyes.mp3 - every 30 min - EyDone - log - Every 30 min
# Physical activity - physical.mp3 every - 45 min - ExDone - log
# Rules
# Pygame module to play audio

from pygame import mixer
from datetime import datetime
from time import time

def musiconloop(file, stopper):
    mixer.init()
    mixer.music.load(file)
    mixer.music.play()
    while True:
        input_of_user = input()
        if input_of_user == stopper:
            mixer.music.stop()
            break

def log_now(msg):
    with open("mylogs.txt", "a") as f:
        f.write(f"{msg} {datetime.now()}\n")

if __name__ == '__main__':
    # musiconloop("water.mp3", "stop")
    init_water = time()
    init_eyes = time()
    init_exercise = time()
    watersecs = 40*60
    exsecs = 30*60
    eyessecs = 45*60

    while True:
        if time() - init_water > watersecs:
            print("Water Drinking time. Enter 'drank' to stop the alarm.")
            musiconloop('water.mp3', 'drank')
            init_water = time()
            log_now("Drank Water at")

        if time() - init_eyes >eyessecs:
            print("Eye exercise time. Enter 'doneeyes' to stop the alarm.")
            musiconloop('eyes.mp3', 'doneeyes')
            init_eyes = time()
            log_now("Eyes Relaxed at")

        if time() - init_exercise > exsecs:
            print("Physical Activity Time. Enter 'donephy' to stop the alarm.")
            musiconloop('physical.mp3', 'donephy')
            init_exercise = time()
            log_now("Physical Activity done at")







