Skip to content

Commit

Permalink
Tried to add support for Linux failing in keyboard module
Browse files Browse the repository at this point in the history
  • Loading branch information
SShubham1 committed Oct 31, 2024
1 parent baeb62f commit 6679a14
Show file tree
Hide file tree
Showing 3 changed files with 4,578 additions and 4,357 deletions.
25 changes: 18 additions & 7 deletions amine/webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
import time
import sqlite3
import logging
import os
import keyboard
import winsound
# if os is windows will import winsound else beepy
if os.name == "nt":
import winsound
import pygetwindow as gw
else:
import beepy
import pywinctl as gw
import pyautogui
import threading
import subprocess
Expand All @@ -12,7 +19,6 @@
import pandas as pd
import seaborn as sns
from io import BytesIO
import pygetwindow as gw
from flask import send_file
import plotly.express as px
from plyer import notification
Expand All @@ -21,7 +27,6 @@
import matplotlib.dates as mdates
from datetime import datetime, timedelta
from flask import Flask, render_template, request, jsonify
import os
import validators
import requests

Expand Down Expand Up @@ -70,6 +75,12 @@ def setup_logging():

return logger

# os depended beep
def amine_beep():
if os.name == "nt":
winsound.Beep(500, 500)
else:
beepy.beep(4)

logger = setup_logging()

Expand All @@ -91,7 +102,7 @@ def on_key_event(event):
if event.name in self.config["BLOCKED_KEYS"]:
logger.warning(f"Attempted To Press Blocked Key : {event.name}")
log_distraction(self.session_id, f"Blocked Key Press : {event.name}")
winsound.Beep(500, 500)
amine_beep()

keyboard.hook(on_key_event)

Expand Down Expand Up @@ -537,13 +548,13 @@ def pomodoro_flow(pomodoros, focus_duration, break_duration, link, link_type):
focus_protection = FocusProtection(session_id=session_id)

for i in range(pomodoros):
winsound.Beep(500, 500)
amine_beep()
notify_user(f"Starting Pomodoro {i + 1}/{pomodoros}")
logger.info(f"Starting Pomodoro {i + 1}/{pomodoros}")
focus_protection.start_protection(focus_duration)

if i < pomodoros - 1:
winsound.Beep(500, 500)
amine_beep()
notify_user("Break time!")
logger.info(f"Break: {break_duration} minutes")
time.sleep(break_duration * 60)
Expand Down Expand Up @@ -571,4 +582,4 @@ def pomodoro_flow(pomodoros, focus_duration, break_duration, link, link_type):

if __name__ == "__main__":
init_db()
FlaskUI(app=app, server="flask", width=470, height=678).run()
FlaskUI(app=app, server="flask", width=470, height=678).run()
Loading

0 comments on commit 6679a14

Please sign in to comment.