From ccdab59f90a2549f6ac27f342105a4cb3a527e7f Mon Sep 17 00:00:00 2001 From: moheladwy Date: Thu, 8 Jan 2026 18:39:57 +0200 Subject: [PATCH 1/3] Enhance setup script with user feedback and ignore vscode AI rules --- .gitignore | 4 ++++ setup.sh | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index f374bac..bad2e07 100644 --- a/.gitignore +++ b/.gitignore @@ -170,3 +170,7 @@ cython_debug/ *.png *.gif output*.txt + + +#Ignore vscode AI rules +.github/instructions/codacy.instructions.md diff --git a/setup.sh b/setup.sh index 75ff9dd..7423ba1 100755 --- a/setup.sh +++ b/setup.sh @@ -53,6 +53,7 @@ x11_session_apps=( # Check if yay is installed. check_yay() { + echo "Checking for yay AUR helper..." if ! command -v yay &>/dev/null; then read -r -p "yay is not installed. Do you want to install yay? (y/n): " choice if [ "$choice" = "y" ]; then @@ -60,32 +61,48 @@ check_yay() { git clone https://aur.archlinux.org/yay.git cd yay || exit makepkg -si --noconfirm + echo "yay has been installed successfully." else echo "Please install yay first!" return 1 fi + else + echo "yay is already installed." fi } # Install the required packages. install_requirements() { + echo "Installing system requirements..." yay -S --noconfirm --needed "${sys_requirements[@]}" if [ "$XDG_SESSION_TYPE" = "wayland" ]; then + echo "Installing Wayland session applications..." yay -S --noconfirm --needed "${wayland_session_apps[@]}" else + echo "Installing X11 session applications..." yay -S --noconfirm --needed "${x11_session_apps[@]}" fi + + echo "All requirements have been installed successfully." } # Main function. main() { + echo "========================================================================================================" + echo "Starting OCR4Linux setup..." + echo "========================================================================================================" check_yay + echo "========================================================================================================" install_requirements - + echo "========================================================================================================" # Copy the script to the user's home directory. + echo "Setting up OCR4Linux configuration..." mkdir -p "$HOME/.config/OCR4Linux" cp -r ./* "$HOME/.config/OCR4Linux" + echo "OCR4Linux has been set up successfully in $HOME/.config/OCR4Linux" + echo "Setup completed. You can now use OCR4Linux." + echo "========================================================================================================" } main From 0ee3555daedf7650635df917d62b47f2a91a9613 Mon Sep 17 00:00:00 2001 From: moheladwy Date: Thu, 8 Jan 2026 19:20:09 +0200 Subject: [PATCH 2/3] Bump version to 1.4.0 in OCR4Linux.sh and setup.sh; add logging for screenshot and clipboard operations --- OCR4Linux.sh | 11 +++++++++-- setup.sh | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/OCR4Linux.sh b/OCR4Linux.sh index 340fb10..eddab60 100755 --- a/OCR4Linux.sh +++ b/OCR4Linux.sh @@ -1,7 +1,7 @@ #!/bin/bash # ======================================================================================================================== # Author: Mohamed Hussein Al-Adawy -# Version: 1.2.0 +# Version: 1.4.0 # Description: # OCR4Linux is a versatile text extraction tool for Linux systems that: # 1. Takes screenshots of selected areas using: @@ -189,14 +189,18 @@ choose_lang() { # take shots using grimblast for wayland takescreenshot_wayland() { + log_message "Taking screenshot using grimblast for Wayland..." sleep $SLEEP_DURATION grimblast --notify copysave area "$SCREENSHOT_DIRECTORY/$SCREENSHOT_NAME" + log_message "Screenshot saved to $SCREENSHOT_DIRECTORY/$SCREENSHOT_NAME in wayland session" } # take shots using scrot for x11 takescreenshot_x11() { + log_message "Taking screenshot using scrot for X11..." sleep $SLEEP_DURATION scrot -s -Z 0 -o -F "$SCREENSHOT_DIRECTORY/$SCREENSHOT_NAME" + log_message "Screenshot saved to $SCREENSHOT_DIRECTORY/$SCREENSHOT_NAME in x11 session" } # Run the screenshot functions based on the session type. @@ -206,7 +210,6 @@ takescreenshot() { else takescreenshot_x11 fi - log_message "Screenshot saved to $SCREENSHOT_DIRECTORY/$SCREENSHOT_NAME" } # Pass the screenshot to OCR tool to extract text from the image. @@ -232,13 +235,17 @@ extract_text() { # Copy the extracted text to clipboard using wl-copy and cliphist. copy_to_wayland_clipboard() { + log_message "Copying extracted text to Wayland clipboard using wl-copy and cliphist..." cliphist store <"$OCR4Linux_HOME/$TEXT_OUTPUT_FILE_NAME" cliphist list | head -n 1 | cliphist decode | wl-copy + log_message "Extracted text copied to Wayland clipboard successfully." } # Copy the extracted text to clipboard using xclip. copy_to_x11_clipboard() { + log_message "Copying extracted text to X11 clipboard using xclip..." xclip -selection clipboard -t text/plain -i "$OCR4Linux_HOME/$TEXT_OUTPUT_FILE_NAME" + log_message "Extracted text copied to X11 clipboard successfully." } # Run the copy to clipboard functions based on the session type. diff --git a/setup.sh b/setup.sh index 7423ba1..b619a70 100755 --- a/setup.sh +++ b/setup.sh @@ -2,7 +2,7 @@ # ======================================================================================================================== # Author: # Mohamed Hussein Al-Adawy -# Version: 1.3.0 +# Version: 1.4.0 # Description: # This setup script installs and configures OCR4Linux and its dependencies. # It handles the installation of: From 984deac14dfb5b2bf27113f5a9bf8f2dfacdb5bc Mon Sep 17 00:00:00 2001 From: moheladwy Date: Tue, 13 Jan 2026 16:40:27 +0200 Subject: [PATCH 3/3] Bump version to 1.4.0 in OCR4Linux.py; enhance clipboard functionality in OCR4Linux.sh for X11 for primary pasting (middle click in the mouse) --- OCR4Linux.py | 2 +- OCR4Linux.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/OCR4Linux.py b/OCR4Linux.py index 38bf376..6bee4c0 100644 --- a/OCR4Linux.py +++ b/OCR4Linux.py @@ -1,7 +1,7 @@ # ======================================================================================================================== # Author: # Mohamed Hussein Al-Adawy -# Version: 1.3.0 +# Version: 1.4.0 # 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 diff --git a/OCR4Linux.sh b/OCR4Linux.sh index eddab60..4031274 100755 --- a/OCR4Linux.sh +++ b/OCR4Linux.sh @@ -244,7 +244,8 @@ copy_to_wayland_clipboard() { # Copy the extracted text to clipboard using xclip. copy_to_x11_clipboard() { log_message "Copying extracted text to X11 clipboard using xclip..." - xclip -selection clipboard -t text/plain -i "$OCR4Linux_HOME/$TEXT_OUTPUT_FILE_NAME" + xclip -selection clipboard -i "$OCR4Linux_HOME/$TEXT_OUTPUT_FILE_NAME" + xclip -selection primary -i "$OCR4Linux_HOME/$TEXT_OUTPUT_FILE_NAME" log_message "Extracted text copied to X11 clipboard successfully." }