Skip to content

Commit

Permalink
Added Pomodoro Timer (#302)
Browse files Browse the repository at this point in the history
* Added Pomodoro Timer

* Update README.md

* Update README.md
  • Loading branch information
max-lopzzz authored Oct 7, 2024
1 parent 215c7ce commit db40916
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Pomodoro Timer/Pomodoro Timer MacOS Linux.py
Original file line number Diff line number Diff line change
@@ -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)
24 changes: 24 additions & 0 deletions Pomodoro Timer/Pomodoro Timer Windows.py
Original file line number Diff line number Diff line change
@@ -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)
33 changes: 33 additions & 0 deletions Pomodoro Timer/README.md
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit db40916

Please sign in to comment.