DEV Community

Cover image for UnDistractor
Aaryan Tahir
Aaryan Tahir

Posted on

UnDistractor

Undistractor is a desktop notification application designed to keep users focused during crucial study sessions or exam preparations by delivering timely reminders. It sends an initial motivational notification alerting users about an upcoming exam, urging them to study, followed by a follow-up notification if the user hasn’t taken action. The system operates in a loop, sending notifications at regular intervals to ensure continuous awareness and motivation. Utilizing the plyer library for notifications and Python’s time and threading modules for scheduling, Undistractor features customizable alerts with user-defined icons to enhance engagement and effectiveness. Ideal for students and professionals needing structured reminders to minimize distractions and boost productivity, this tool helps users stay on track and achieve their goals.

from plyer import notification
import time
import threading

# Function to send the initial notification
def send_initial_notification():
    title = 'DONT GET DISTRACTED !'
    message = 'Exam in 6 hrs, You better Study'
    notification.notify(
        title=title,
        message=message,
        app_icon=r"C:\Users\Aaryan\Desktop\CODE\Projects\Undistractor\heart.ico",
        timeout=5,  # Notification stays for 5 seconds
        toast=False
    )

# Function to send a follow-up notification if needed
def send_follow_up_notification():
    title = 'CLOSING ME WONT HELP!'
    message = 'You still need to study!'
    notification.notify(
        title=title,
        message=message,
        app_icon=r"C:\Users\Aaryan\Desktop\CODE\Projects\Undistractor\heart.ico",
        timeout=5,  # Notification stays for 5 seconds
        toast=False
    )

# Function to check and send follow-up notification
def check_and_notify():
    while True:
        send_initial_notification()
        # Wait for 60 seconds before sending follow-up notification
        time.sleep(2)  # Adjust sleep time as needed
        send_follow_up_notification()
        # Sleep for 5 hours before sending the initial notification again
        time.sleep(10)  # 5 hours

# Run the notification checker in a separate thread
thread = threading.Thread(target=check_and_notify)
thread.start()

Enter fullscreen mode Exit fullscreen mode

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay