From db40916edfc02183d83030ba6cd3c9ca4cd23775 Mon Sep 17 00:00:00 2001 From: Maximiliano Date: Mon, 7 Oct 2024 05:46:34 -0600 Subject: [PATCH] Added Pomodoro Timer (#302) * Added Pomodoro Timer * Update README.md * Update README.md --- Pomodoro Timer/Pomodoro Timer MacOS Linux.py | 24 ++++++++++++++ Pomodoro Timer/Pomodoro Timer Windows.py | 24 ++++++++++++++ Pomodoro Timer/README.md | 33 ++++++++++++++++++++ README.md | 1 + 4 files changed, 82 insertions(+) create mode 100644 Pomodoro Timer/Pomodoro Timer MacOS Linux.py create mode 100644 Pomodoro Timer/Pomodoro Timer Windows.py create mode 100644 Pomodoro Timer/README.md diff --git a/Pomodoro Timer/Pomodoro Timer MacOS Linux.py b/Pomodoro Timer/Pomodoro Timer MacOS Linux.py new file mode 100644 index 0000000..43fca53 --- /dev/null +++ b/Pomodoro Timer/Pomodoro Timer MacOS Linux.py @@ -0,0 +1,24 @@ +# Pomodoro Timer for macOS/Linux +import time +import os + +def pomodoro_timer_unix(work_duration=25, break_duration=5, cycles=4): + for cycle in range(cycles): + print(f"Cycle {cycle + 1}/{cycles}: Start working for {work_duration} minutes.") + time.sleep(work_duration * 60) + os.system('echo -e "\a"') # Make a beep sound on macOS/Linux + print("Time's up! Take a break.") + + print(f"Break time! Relax for {break_duration} minutes.") + time.sleep(break_duration * 60) + os.system('echo -e "\a"') # Make a beep sound on macOS/Linux + print("Break is over! Back to work.") + + print("All cycles completed! Great job!") + +if __name__ == "__main__": + work_duration = int(input("Enter work duration in minutes (default is 25): ") or 25) + break_duration = int(input("Enter break duration in minutes (default is 5): ") or 5) + cycles = int(input("Enter number of cycles (default is 4): ") or 4) + + pomodoro_timer_unix(work_duration, break_duration, cycles) diff --git a/Pomodoro Timer/Pomodoro Timer Windows.py b/Pomodoro Timer/Pomodoro Timer Windows.py new file mode 100644 index 0000000..8687c95 --- /dev/null +++ b/Pomodoro Timer/Pomodoro Timer Windows.py @@ -0,0 +1,24 @@ +# Pomodoro Timer for Windows +import time +import winsound + +def pomodoro_timer_windows(work_duration=25, break_duration=5, cycles=4): + for cycle in range(cycles): + print(f"Cycle {cycle + 1}/{cycles}: Start working for {work_duration} minutes.") + time.sleep(work_duration * 60) + winsound.Beep(1000, 1000) # Sound an alert to indicate work period end + print("Time's up! Take a break.") + + print(f"Break time! Relax for {break_duration} minutes.") + time.sleep(break_duration * 60) + winsound.Beep(1000, 1000) # Sound an alert to indicate break period end + print("Break is over! Back to work.") + + print("All cycles completed! Great job!") + +if __name__ == "__main__": + work_duration = int(input("Enter work duration in minutes (default is 25): ") or 25) + break_duration = int(input("Enter break duration in minutes (default is 5): ") or 5) + cycles = int(input("Enter number of cycles (default is 4): ") or 4) + + pomodoro_timer_windows(work_duration, break_duration, cycles) diff --git a/Pomodoro Timer/README.md b/Pomodoro Timer/README.md new file mode 100644 index 0000000..b162091 --- /dev/null +++ b/Pomodoro Timer/README.md @@ -0,0 +1,33 @@ +# Pomodoro Timer +## 📋 Overview +The Pomodoro Timer is a productivity tool designed to help you manage your time efficiently using the Pomodoro Technique. It splits your work into intervals—typically 25 minutes of focused work followed by a 5-minute break. This cycle helps to boost focus and prevent burnout by encouraging regular breaks. The script is cross-platform, supporting both Windows and macOS/Linux. + +## ✨ Features +- **Customizable Work and Break Durations:** Set your preferred time for work and break sessions. +- **Support for Multiple Cycles:** Run multiple Pomodoro sessions in a row. +- **Platform-Specific Alerts:** +- **Windows:** Uses sound alerts (winsound) to notify users when a session is complete. +- **macOS/Linux:** Uses terminal beep commands for notifications. + +## Running the script +1. **Clone the Repository or Download the Script:** +- clone the repository: +``` +git clone https://github.com/max-lopzzz/Python-Scripts/tree/master/Pomodoro%20Timer +``` +- Or download the script directly from the repository page. +2. **Navigate to the Script Location:** Open your terminal (Command Prompt on Windows, Terminal on macOS/Linux) and navigate to the folder containing the script: +``` +cd path/to/your/script +``` +3. **Run the Script:** Execute the script using Python: +``` +python pomodoro_timer.py +``` +or, if `python` points to Python 2.x on your system: +``` +python3 pomodoro_timer.py +``` +### Customizing Durations +- Once the script runs, it may prompt you to enter custom durations for both work and break intervals. +- Simply follow the prompts to customize your session lengths. diff --git a/README.md b/README.md index b5ac43d..97710f0 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,7 @@ More information on contributing and the general code of conduct for discussion | Playlist Exchange | [Playlist Exchange](https://github.com/DhanushNehru/Python-Scripts/tree/master/Playlist%20Exchange) | A Python script to exchange songs and playlists between Spotify and Python. | Pigeonhole Sort | [Algorithm](https://github.com/DhanushNehru/Python-Scripts/tree/master/PigeonHole) | The pigeonhole sort algorithm to sort your arrays efficiently! | PNG TO JPG CONVERTOR | [PNG-To-JPG](https://github.com/DhanushNehru/Python-Scripts/tree/master/PNG%20To%20JPG) | A PNG TO JPG IMAGE CONVERTOR. +| Pomodoro Timer | [Pomodoro Timer](https://github.com/DhanushNehru/Python-Scripts/tree/master/Pomodoro%20Timer) | A Pomodoro timer | Python GUI Notepad | [Python GUI Notepad](https://github.com/DhanushNehru/Python-Scripts/blob/master/PDF%20Merger%20and%20Splitter/PDF%20Merger%20and%20Splitter.py) | A Python-based GUI Notepad with essential features like saving, opening, editing text files, basic formatting, and a simple user interface for quick note-taking. | QR Code Generator | [QR Code Generator](https://github.com/DhanushNehru/Python-Scripts/tree/master/QR%20Code%20Generator) | This is generate a QR code from the provided link | | QR Code with logo | [QR code with Logo](https://github.com/DhanushNehru/Python-Scripts/tree/master/QR%20with%20Logo) | QR Code Customization Feature