Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
datavorous committed Aug 29, 2024
1 parent 4f4eb6b commit 37ba3c8
Showing 1 changed file with 82 additions and 25 deletions.
107 changes: 82 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,101 @@
# amine
<div align="center">

<img src="demo.png" width="80%">
# amine

### Why this? Well, popular website blockers are not equipped enough, willpower can't be trusted, Cold Turkey ain't got so much flexibilty, and i need to pass my exams.
<img src="thumb1.png" width="80%">

### **1. Working Mechanism**
</div>

**Amine** is a Flask-based application that combines a Pomodoro timer with advanced distraction-blocking techniques. The application allows users to define work sessions (Pomodoros) and breaks while enforcing focus by restricting certain keys and preventing the mouse from accessing certain screen areas. This ensures the user remains undistracted during their focus sessions.
## Features

### **2. Logic Handling**
- **Customizable Pomodoro Sessions**: Set the number of sessions, focus duration, and break duration.
- **Strict Distraction Blocking**:
- Blocks key combinations that might disrupt focus (e.g., Windows key, Alt+Tab).
- Prevents mouse movement to screen edges.
- **Fullscreen Enforcement**: Automatically enters fullscreen mode for the chosen focus website.
- **Safe Exit Mechanism**: Allows users to exit using a predefined key combination (Ctrl+Shift+Q).
- **User-Friendly Interface**: Clean, responsive design built with HTML, Tailwind CSS, and custom fonts.

#### **a. Pomodoro Timer Logic:**
- **Pomodoro Sessions**: The user can configure the number of Pomodoros, focus duration, break duration, and the target website to open during the session.
- **Flow Execution**: The Pomodoro flow is handled by the `pomodoro_flow` function, which launches a new thread for the session and handles the sequence of Pomodoro sessions and breaks.
## Comparison

#### **b. Focus Protection Logic:**
- **Distraction Blocking**: A `FocusProtection` class is responsible for enforcing focus by blocking specific keys and restricting mouse movement.
- **Key Blocking**: All keys listed in the `CONFIG["BLOCKED_KEYS"]` array are blocked during focus sessions using the `keyboard` module.
- **Mouse Boundaries**: The `enforce_mouse_boundaries` method ensures the mouse cursor stays away from screen edges where potential distractions (like tabs or taskbars) could reside. If the mouse crosses the defined `TOP_SCREEN_THRESHOLD`, it is moved back to a safe position.
| Feature | amine | Freedom | RescueTime | Cold Turkey | Standard Pomodoro Timers |
|---------|-------|---------|------------|-------------|--------------------------|
| Website Blocking ||||||
| Fullscreen Enforcement ||||||
| Key Combination Blocking ||||||
| Mouse Movement Restriction ||||||
| Customizable Sessions ||||||
| Local Application (No Account Needed) ||||| Varies |

### **3. Threading and Concurrent Execution**
## Technical Stack

- **Threading for Concurrent Tasks**: The application uses Python's `threading` module to manage concurrent tasks, such as running the Pomodoro timer and enforcing focus protection simultaneously. This ensures that while the main timer is running, the distraction-blocking measures are active.

- **Daemon Threads**: The mouse boundary enforcement runs on a daemon thread, meaning it runs in the background and stops automatically when the main program exits.
- **Backend**: Python with Flask
- **Frontend**: HTML, JavaScript, Tailwind CSS
- **GUI**: FlaskWebGUI
- **Dependency Management**: Poetry
- **Additional Libraries**: pyautogui, keyboard, pygetwindow, winsound

### **4. Clever Mechanisms and Design Decisions**
## Technical Insights

- **Exit Combo for Safety**: The application allows users to exit the focus session early using a configurable keyboard shortcut (`ctrl+shift+q`). This combo is constantly checked during focus sessions to allow a quick escape without needing to modify the code.
1. **Multithreading**: The application uses Python's threading module to run the Pomodoro timer and mouse boundary enforcement concurrently with the main Flask application.

- **Window Management**: The application automatically minimizes the Flask window when a Pomodoro session starts and restores it after all Pomodoros are completed. This minimizes distractions and brings the user back to the application's interface when the session ends.
2. **Low-Level Input Blocking**: Utilizes the `keyboard` library to block specific key combinations at a system level, providing robust protection against common distraction patterns.

- **Mouse Enforcement with Adjustable Delay**: The mouse enforcement delay is configurable (`MOUSE_ENFORCE_DELAY`), allowing for smoother or stricter control over the mouse movement depending on user preferences.
3. **Window Management**: Employs `pygetwindow` to manipulate application windows, ensuring the focus stays on the target website.

### **5. Unique Features Compared to Other Blockers**
4. **Custom GUI with Flask**: Leverages FlaskWebGUI to create a desktop application experience using web technologies, allowing for a responsive and easily customizable interface.

- **Integrated Pomodoro Timer**: Unlike other tools like Freedom or RescueTime, Amine integrates a Pomodoro timer with distraction blocking, offering a seamless experience for users who follow the Pomodoro technique.
5. **Tailwind CSS Integration**: Uses Tailwind CSS via CDN for rapid UI development and consistent styling across the application.

- **Custom Key Blocking**: The app allows for precise control over which keys are blocked, ensuring that the user cannot open task managers, switch windows, or exit full-screen mode accidentally.
## Setup and Installation

- **Mouse Boundary Enforcement**: Amine uniquely ensures that the user’s mouse stays away from potentially distracting screen areas, unlike most focus tools that only block websites or apps.
1. Clone the repository:
```
git clone https://github.com/datavorous/amine.git
cd amine
```

2. Install Poetry (if not already installed):
```
pip install poetry
```

3. Install dependencies using Poetry:
```
poetry install
```

4. Run the application:
```
cd amine
poetry run python webapp.py
```

## Usage

1. Launch the application.
2. On the main page, set your desired Pomodoro parameters:
- Number of sessions
- Focus duration (in minutes)
- Break duration (in minutes)
- Website URL for focusing
3. Click "Start" to begin your Pomodoro session.
4. The application will open your chosen website in fullscreen mode and start the timer.
5. To exit at any time, use the key combination Ctrl+Shift+Q.

## Important Notes

- Avoid manually exiting fullscreen mode or moving your mouse to screen edges during a session.
- The application may perform an initial page click to ensure fullscreen mode, which could cause minor disruptions.

## Contributing

Contributions to amine are welcome. Please feel free to submit a Pull Request.

## Support

For support, please email [[email protected]](mailto:[email protected]).

## License

[MIT License](LICENSE)

0 comments on commit 37ba3c8

Please sign in to comment.