Many times, you want to review some code and understand exactly what it does, but you don’t feel like copy-pasting it into an AI tool. With this repo, you can simply highlight the code and press a keyboard shortcut to instantly bring up the code explanation panel right in front of you.
This lightweight Linux tool reads the code you’ve selected and uses an LLM (Gemini model) to generate a concise explanation in Persian. The UI is built with GTK3, and you can close the window by pressing Space.
- Concise Persian explanation: A 3–4 line summary of the code’s purpose and key points
- Two-pane panel: Shows “Selected Code” and “Explanation” side by side
- Automatic syntax highlighting
- Close shortcut: Space key
- Operating system: Linux
- Python: Version 3.10 or newer
- System dependencies:
- Debian/Ubuntu:
sudo apt update sudo apt install -y python3 python3-venv python3-pip python3-gi gir1.2-gtk-3.0 xclip libnotify-bin
- Fedora/RHEL:
sudo dnf install -y python3 python3-pip python3-gi gtk3 xclip libnotify
- Arch:
sudo pacman -S --needed python python-pip python-gobject gtk3 xclip libnotify
- Debian/Ubuntu:
From the repository root:
cd Code_Explainer
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtHow to get a free API key from Google AI Studio
To use this project, you need to obtain an API key from Studio AI. Steps to get the API key:
Place the key in api/gemini_api.py by replacing the GEMINI_API_KEY variable.
To quickly run main.py with a keyboard shortcut on Linux, follow these steps:
-
Ensure the script is executable:
chmod +x path/to/main.py
-
To create a desktop environment shortcut (e.g., GNOME), go to:
Settings → Keyboard → View and Customize Shortcuts → Customize Shortcuts -
Create a new custom shortcut and fill in the following:
- Name: Any name (e.g.,
Code Explainer) - Command: The full path to run
main.py, for example:python3 /full/path/to/main.py
- Shortcut: Your preferred key combo (e.g., Ctrl+Q)
- Name: Any name (e.g.,
-
Test the saved shortcut. When you press the defined key combo, the script should run.
