Skip to content

CodeGate is a Linux productivity tool that blocks distracting applications and requires you to solve a coding challenge to regain access.

License

Notifications You must be signed in to change notification settings

mouwaficbdr/codegate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

23 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CodeGate

CodeGate is an innovative Linux productivity tool that blocks your distracting applications and forces you to solve a coding challenge to access them.

🎯 Goal: Improve your personal discipline while boosting your programming skills.

CodeGate Challenge UI


Features

πŸ”’ Smart Blocking

  • Continuous monitoring of configured applications
  • Instant blocking via SIGSTOP (without killing the app)
  • Fast detection (0.3s) to intercept launches
  • Anti-bypass protection with watchdog

πŸ’» Coding Challenges

  • Various algorithmic problems
  • Multi-language support: Python β€’ JavaScript β€’ PHP
  • Difficulty levels: Easy, Medium, Hard, Mixed
  • 200+ built-in challenges
  • Editor with syntax highlighting

CodeGate Settings

πŸ›‘οΈ Robustness

  • Watchdog: Automatically restarts if CodeGate is closed
  • Config protection: Detects modifications using SHA256 checksums
  • Auto-start: Activates on each login
  • Detailed logs: Automatic rotation (5MB)

πŸ“Š Statistics

  • Daily and total blocks
  • Challenges solved/failed
  • Success rate
  • Full history

Modern Interface

  • PySide6 graphical interface
  • Welcome wizard for initial setup
  • App selection with categories
  • System notifications
  • Real-time search

πŸ“‹ Requirements

  • OS: Linux (tested on Ubuntu/Debian)
  • Python: 3.10+
  • Node.js: For JavaScript challenges (v14+ recommended)
  • PHP: For PHP challenges (v7.4+ recommended)
  • Environment: Desktop with window manager

ℹ️ Note: The installation script can automatically install Node.js and PHP if they’re missing. You can also use only Python if you prefer.


πŸš€ Installation

Automatic method (recommended)

# Clone the repository
git clone https://github.com/mouwaficbdr/codegate.git
cd codegate

# Run the installer
./install.sh

The script will:

  • βœ… Check Python 3.10+
  • βœ… Create a virtual environment
  • βœ… Install dependencies
  • βœ… Configure auto-start
  • βœ… Create required folders

Manual installation

# 1. Create the virtual environment
python3 -m venv venv
source venv/bin/activate

# 2. Install dependencies
pip install -r requirements.txt

# 3. Copy the autostart file
mkdir -p ~/.config/autostart
cp codegate.desktop ~/.config/autostart/

# 4. Edit the path in codegate.desktop
nano ~/.config/autostart/codegate.desktop
# Replace /home/mouwaficbdr/Code/codegate with your path

Usage

First launch

On first start, a configuration wizard guides you:

App Selection Difficulty Summary

  1. Welcome: Introduction to the concept
  2. App selection: Choose apps to block
  3. Difficulty: Challenge difficulty
  4. Summary: Review and validate

Daily usage

CodeGate runs in the background and can be controlled in multiple ways:

Via CLI (Recommended)

# Open the dashboard
codegate open

# Check if CodeGate is running
codegate status

# Quit CodeGate
codegate quit

Via System Tray

Look for the πŸ›‘οΈ CodeGate icon in your system tray (usually near the clock):

  • Click to open the menu
  • Select Settings to configure apps
  • Select Quit to stop CodeGate

When an app is blocked

  1. CodeGate starts automatically at login

  2. Configured apps are monitored

  3. If you launch a blocked app:

    • ⏸️ The app is paused (SIGSTOP)
    • πŸ“ A full-screen challenge appears
    • πŸ’» Solve the challenge
    • βœ… The app unlocks upon success

CLI Commands

Command Action
codegate open Open the dashboard window
codegate config Alias for open
codegate dashboard Alias for open
codegate status Check if CodeGate is running
codegate quit Stop CodeGate daemon
codegate help Show help

Settings

Access settings via:

  • CLI: codegate open
  • Tray Icon: Click the βš™οΈ icon

You can:

  • Modify blocked applications
  • Change difficulty
  • Add custom apps
  • View statistics

πŸ“ Architecture

codegate/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ main.py                   # Main entry point
β”‚   β”œβ”€β”€ main_gui.py               # Challenge overlay interface
β”‚   β”œβ”€β”€ dashboard.py              # Dashboard window (settings)
β”‚   β”œβ”€β”€ ipc_server.py             # CLI communication server
β”‚   β”œβ”€β”€ watchdog.py               # Anti-kill protection
β”‚   β”œβ”€β”€ process_blocker.py        # Process blocking
β”‚   β”œβ”€β”€ process_monitor.py        # Advanced detection
β”‚   β”œβ”€β”€ config_protector.py       # Config protection
β”‚   β”œβ”€β”€ code_runner.py            # User code execution
β”‚   β”œβ”€β”€ challenge_fetcher.py      # Challenge retrieval
β”‚   β”œβ”€β”€ notification_manager.py   # System notifications
β”‚   β”œβ”€β”€ tray_icon.py              # System tray icon
β”‚   β”œβ”€β”€ logger.py                 # Centralized logs
β”‚   β”œβ”€β”€ onboarding.py             # First-use wizard
β”‚   └── i18n_manager.py           # Internationalization
β”œβ”€β”€ bin/
β”‚   └── codegate                  # CLI script
β”œβ”€β”€ assets/
β”‚   β”œβ”€β”€ challenges.json           # Database of 200+ challenges
β”‚   └── codegate_icon.svg         # App icon
β”œβ”€β”€ install.sh                    # Installation script
β”œβ”€β”€ uninstall.sh                  # Uninstallation script
β”œβ”€β”€ run_codegate.sh               # Watchdog launcher
β”œβ”€β”€ codegate.desktop              # Autostart file
└── config.json                   # User configuration

πŸ”§ Advanced configuration

config.json file

{
    "blocked_apps": ["discord", "firefox", "steam"],
    "custom_apps": ["my-app"],
    "language": "fr",
    "difficulty_mode": "Mixed",
    "first_run": false
}

Logs

Location: ~/.local/share/codegate/logs/

  • codegate.log: Main logs (5MB rotation)
  • errors.log: Errors only
  • watchdog.log: Watchdog logs

Statistics

File: ~/.local/share/codegate/stats.json


❓ FAQ

Q: Does CodeGate work offline? A: Yes! All challenges are stored locally.

Q: Can I temporarily disable CodeGate? A: Yes, use codegate quit or click "Quit" in the system tray. The watchdog will NOT restart it automatically when quit properly.

Q: How to fully uninstall it? A: Run ./uninstall.sh, which cleans everything.

Q: Can I add my own challenges? A: Yes, edit assets/challenges.json (see structure).

Q: Does CodeGate require sudo? A: No for usage. Optional for system-level installation.


Troubleshooting

CodeGate doesn’t start

# Check logs
cat ~/.local/share/codegate/logs/codegate.log

# Test manually
./run_codegate.sh

Apps don’t get blocked

  1. Check if the app is in the list
  2. Check the process name: ps aux | grep appname
  3. Check logs for errors

β€œVirtual environment not found” error

# Recreate venv
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

For more help, see docs/TROUBLESHOOTING.md.


🀝 Contributing

Contributions are welcome!

  1. Fork the project
  2. Create a branch (git checkout -b feature/AmazingFeature)
  3. Commit (git commit -m 'Add AmazingFeature')
  4. Push (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

MIT License β€” See the LICENSE file for details.


Made with ❀️ for focused devs

About

CodeGate is a Linux productivity tool that blocks distracting applications and requires you to solve a coding challenge to regain access.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •