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
37 changes: 20 additions & 17 deletions .github/workflows/bash-lint.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
name: Bash Lint

permissions:
contents: read

on:
push:
branches:
- main
pull_request:
branches:
- main
push:
branches:
- main
pull_request:
branches:
- main

jobs:
lint:
runs-on: ubuntu-latest
lint:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install ShellCheck
run: sudo apt-get install -y shellcheck
- name: Install ShellCheck
run: sudo apt-get install -y shellcheck

- name: Lint setup.sh
run: shellcheck setup.sh
- name: Lint setup.sh
run: shellcheck setup.sh

- name: Lint OCR4Linux.sh
run: shellcheck OCR4Linux.sh
- name: Lint OCR4Linux.sh
run: shellcheck OCR4Linux.sh
3 changes: 3 additions & 0 deletions .github/workflows/python-lint.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Python Lint

permissions:
contents: read

on:
push:
branches:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,5 @@ output*.txt

#Ignore vscode AI rules
.github/instructions/codacy.instructions.md
.github/plans/
.codacy/
2 changes: 1 addition & 1 deletion OCR4Linux.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ========================================================================================================================
# Author:
# Mohamed Hussein Al-Adawy
# Version: 1.4.0
# Version: 1.4.1
# Description:
# OCR4Linux.py is a Python script that handles image preprocessing and text extraction using Tesseract OCR.
# The script takes an input image, processes it for optimal OCR accuracy, and extracts text while preserving
Expand Down
45 changes: 32 additions & 13 deletions OCR4Linux.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
# ========================================================================================================================
# Author: Mohamed Hussein Al-Adawy
# Version: 1.4.0
# Version: 1.4.1
# Description:
# OCR4Linux is a versatile text extraction tool for Linux systems that:
# 1. Takes screenshots of selected areas using:
Expand Down Expand Up @@ -45,25 +45,52 @@ SPECIFIED_LANGS=""

langs=()

# Add log function
log_message() {
local message
message="[$(date '+%Y-%m-%d %H:%M:%S')] $1"
echo "$message" >&2
if [ "$KEEP_LOGS" = true ]; then
{
echo "$message"
} >>"$OCR4Linux_HOME/$LOGS_FILE_NAME"
fi
}

# Perform update by running setup.sh from source directory
perform_update() {
echo "To perform a full update, please git pull the latest version from the GitHub repository:"
echo "1) cd ~/src/OCR4Linux # If you haven't cloned it yet, run: git clone https://github.com/moheladwy/OCR4Linux.git ~/src/OCR4Linux"
echo "2) git pull"
echo "3) Then run the setup script:"
echo "4) chmod +x ./setup.sh"
echo "5) ./setup.sh"
echo "The setup script will update the OCR4Linux scripts and dependencies to the latest version."
}

# Display help message
show_help() {
echo "Usage: $(basename "$0") [OPTIONS]"
echo "Options:"
echo " -r Remove screenshot in the screenshot directory"
echo " -d DIRECTORY Set screenshot directory (default: $SCREENSHOT_DIRECTORY)"
echo " -l Keep logs"
echo " -u, --update Update OCR4Linux (scripts and dependencies)"
echo " --lang LANGUAGES Specify OCR languages (e.g., 'all', 'eng', 'eng+ara')"
echo " -h 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 -u"
echo " OCR4Linux.sh --update"
echo " OCR4Linux.sh -h"
echo "Note:"
echo " - If --lang is not specified, an interactive language selection menu will appear"
echo " - Use 'all' to select all available languages"
echo " - Use '+' to separate multiple languages (e.g., 'eng+ara+fra')"
echo " - Without arguments, screenshots are saved to $SCREENSHOT_DIRECTORY"
echo " - The -u or --update option gives instructions on how to update OCR4Linux."
}

# Parse command line arguments
Expand All @@ -81,6 +108,10 @@ while [[ $# -gt 0 ]]; do
KEEP_LOGS=true
shift
;;
-u|--update)
perform_update
exit 0
;;
--lang)
SPECIFIED_LANGS="$2"
LANG_SPECIFIED=true
Expand All @@ -98,18 +129,6 @@ while [[ $# -gt 0 ]]; do
esac
done

# Add log function
log_message() {
local message
message="[$(date '+%Y-%m-%d %H:%M:%S')] $1"
echo "$message" >&2
if [ "$KEEP_LOGS" = true ]; then
{
echo "$message"
} >>"$OCR4Linux_HOME/$LOGS_FILE_NAME"
fi
}

# Check if the required files exist.
check_if_files_exist() {
log_message "Checking required files and directories..."
Expand Down
2 changes: 1 addition & 1 deletion setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# ========================================================================================================================
# Author:
# Mohamed Hussein Al-Adawy
# Version: 1.4.0
# Version: 1.4.1
# Description:
# This setup script installs and configures OCR4Linux and its dependencies.
# It handles the installation of:
Expand Down