Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .SRCINFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pkgbase = ocr4linux-git
pkgdesc = OCR CLI Tool for Extracting Text from Screenshots using bash and python for both x11 and wayland.
pkgver = 1.4.2.r56.4b6a174
pkgver = 1.4.2.r57.e7e63f9
pkgrel = 1
url = https://github.com/moheladwy/OCR4Linux
arch = any
Expand All @@ -23,7 +23,7 @@ pkgbase = ocr4linux-git
depends = scrot
depends = rofi
provides = OCR4Linux
source = ocr4linux-git-1.4.2.r56.4b6a174::git+https://github.com/moheladwy/OCR4Linux
source = ocr4linux-git-1.4.2.r57.e7e63f9::git+https://github.com/moheladwy/OCR4Linux
sha256sums = SKIP

pkgname = ocr4linux-git
16 changes: 13 additions & 3 deletions OCR4Linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@

SCREENSHOT_NAME="screenshot_$(date +%d%m%Y_%H%M%S).jpg"
SCREENSHOT_DIRECTORY="$HOME/Pictures/screenshots"
OCR4Linux_HOME="$(pwd)"
# Get the absolute path of the script itself, handling symlinks
SCRIPT_PATH=$(realpath "$0")
# Extract the directory part
OCR4Linux_HOME="$(dirname "$SCRIPT_PATH")"
OCR4Linux_PYTHON_NAME="OCR4Linux.py"
OCR4Linux_CONFIG="$HOME/.config/OCR4Linux"
TEXT_OUTPUT_FILE_NAME="$OCR4Linux_CONFIG/output_text.txt"
Expand All @@ -43,6 +46,7 @@ REMOVE_SCREENSHOT=false
KEEP_LOGS=false
LANG_SPECIFIED=false
SPECIFIED_LANGS=""
VERSION="v1.4.2"

langs=()

Expand All @@ -66,12 +70,14 @@ show_help() {
echo " -d DIRECTORY Set screenshot directory (default: $SCREENSHOT_DIRECTORY)"
echo " -l Keep logs"
echo " --lang LANGUAGES Specify OCR languages (e.g., 'all', 'eng', 'eng+ara')"
echo " -h Show this help message, then exit"
echo " -v | --version Print the package version, then exist"
echo " -h | --help Show this help message, then exit"
echo "Example:"
echo " OCR4Linux.sh -d $HOME/screenshots -l"
echo " OCR4Linux.sh --lang eng+ara"
echo " OCR4Linux.sh --lang all -l"
echo " OCR4Linux.sh -h"
echo " OCR4Linux.sh -v"
echo "Note:"
echo " - If --lang is not specified, an interactive language selection menu will appear"
echo " - Use 'all' to select all available languages"
Expand Down Expand Up @@ -99,10 +105,14 @@ while [[ $# -gt 0 ]]; do
LANG_SPECIFIED=true
shift 2
;;
-h)
-h|--help)
show_help
exit 0
;;
-v|--version)
echo "${VERSION}"
exit 0
;;
*)
echo "Unknown option: $1"
show_help
Expand Down
2 changes: 1 addition & 1 deletion PKGBUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Maintainer: moheladwy <mohamed.h.eladwy@gmail.com>
pkgname=ocr4linux-git
pkgver=1.4.2.r56.4b6a174
pkgver=1.4.2.r57.e7e63f9
pkgrel=1
pkgdesc="OCR CLI Tool for Extracting Text from Screenshots using bash and python for both x11 and wayland."
arch=('any')
Expand Down
31 changes: 23 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ I didn't find any easy tool in Linux that does the same thing as the PowerTool a
- `tesseract` OCR engine
- `tesseract-data-eng` English language pack
- `tesseract-data-ara` Arabic language pack
- `rofi` for the interactive language selection feature.
- If you need any other language other than the above two, search for it using the command:

```sh
Expand All @@ -64,16 +65,24 @@ I didn't find any easy tool in Linux that does the same thing as the PowerTool a
- `grimblast-git`
- `wl-clipboard`
- `cliphist`
- `rofi-wayland`
- X11:
- `scrot`
- `xclip`
- `rofi`

**Note:** `rofi` is required for the interactive language selection feature.

## Installation

### Option 1: Install from AUR (Recommended)

The easiest way to install OCR4Linux on Arch Linux or any Arch-based distribution is directly from the AUR:

```sh
yay -S ocr4linux-git
```

This will automatically install OCR4Linux and all its required dependencies.

### Option 2: Manual Installation

1. Clone the repository:

```sh
Expand All @@ -90,6 +99,7 @@ I didn't find any easy tool in Linux that does the same thing as the PowerTool a

**Note:** The setup script will:

- Prompt you to confirm before proceeding with the manual installation
- Install all required dependencies (tesseract, rofi, screenshot tools, etc.)
- Copy all OCR4Linux files to `~/.config/OCR4Linux/`
- Set up the necessary directory structure
Expand All @@ -116,7 +126,9 @@ I didn't find any easy tool in Linux that does the same thing as the PowerTool a
- Allow you to select one or multiple languages for OCR processing
- Take a screenshot of the selected area after language selection
- Extract text from the image using the selected languages
- Copy the extracted text to the clipboard### Language Selection
- Copy the extracted text to the clipboard

### Language Selection

You have two options for language selection:

Expand Down Expand Up @@ -162,9 +174,9 @@ The complete OCR4Linux workflow:
| `-r` | Remove screenshot after processing | `false` |
| `-d DIR` | Set screenshot directory | `$HOME/Pictures/screenshots` |
| `-l` | Keep logs | `false` |
| `-u, --update` | Show update instructions | - |
| `--lang LANGUAGES` | Specify OCR languages (bypasses rofi) | Interactive selection |
| `-h` | Show help message | - |
| `-v, --version` | Print the package version, then exit | - |
| `-h, --help` | Show help message, then exit | - |

**Language Format for `--lang`**:

Expand Down Expand Up @@ -209,6 +221,9 @@ The complete OCR4Linux workflow:
./OCR4Linux.sh --lang eng -l -r
./OCR4Linux.sh --lang all -d ~/screenshots -l

# Print version
./OCR4Linux.sh -v

# Show help
./OCR4Linux.sh -h
```
Expand Down Expand Up @@ -289,7 +304,7 @@ python OCR4Linux.py --help

- [OCR4Linux.py](https://github.com/moheladwy/OCR4Linux/blob/main/OCR4Linux.py): Python script to preprocess the image and extract text using `tesseract` with support for custom language selection.
- [OCR4Linux.sh](https://github.com/moheladwy/OCR4Linux/blob/main/OCR4Linux.sh): Shell script that provides both interactive language selection via rofi and direct command-line language specification, takes a screenshot, passes it to the python script with selected languages, gets the extracted text, and copies it to the clipboard.
- [setup.sh](https://github.com/moheladwy/OCR4Linux/blob/main/setup.sh): Shell script to install the required packages and copy the necessary files to the configuration directory (run this script the first time you clone the repository only).
- [setup.sh](https://github.com/moheladwy/OCR4Linux/blob/main/setup.sh): Shell script to install the required packages and copy the necessary files to the configuration directory. Intended for manual installation only — Arch-based users are encouraged to use the AUR package instead.

## Contributing

Expand Down
Loading