11#! /bin/bash
22# ========================================================================================================================
33# Author: Mohamed Hussein Al-Adawy
4- # Version: 1.4.0
4+ # Version: 1.4.1
55# Description:
66# OCR4Linux is a versatile text extraction tool for Linux systems that:
77# 1. Takes screenshots of selected areas using:
@@ -45,25 +45,52 @@ SPECIFIED_LANGS=""
4545
4646langs=()
4747
48+ # Add log function
49+ log_message () {
50+ local message
51+ message=" [$( date ' +%Y-%m-%d %H:%M:%S' ) ] $1 "
52+ echo " $message " >&2
53+ if [ " $KEEP_LOGS " = true ]; then
54+ {
55+ echo " $message "
56+ } >> " $OCR4Linux_HOME /$LOGS_FILE_NAME "
57+ fi
58+ }
59+
60+ # Perform update by running setup.sh from source directory
61+ perform_update () {
62+ echo " To perform a full update, please git pull the latest version from the GitHub repository:"
63+ echo " 1) cd ~/src/OCR4Linux # If you haven't cloned it yet, run: git clone https://github.com/moheladwy/OCR4Linux.git ~/src/OCR4Linux"
64+ echo " 2) git pull"
65+ echo " 3) Then run the setup script:"
66+ echo " 4) chmod +x ./setup.sh"
67+ echo " 5) ./setup.sh"
68+ echo " The setup script will update the OCR4Linux scripts and dependencies to the latest version."
69+ }
70+
4871# Display help message
4972show_help () {
5073 echo " Usage: $( basename " $0 " ) [OPTIONS]"
5174 echo " Options:"
5275 echo " -r Remove screenshot in the screenshot directory"
5376 echo " -d DIRECTORY Set screenshot directory (default: $SCREENSHOT_DIRECTORY )"
5477 echo " -l Keep logs"
78+ echo " -u, --update Update OCR4Linux (scripts and dependencies)"
5579 echo " --lang LANGUAGES Specify OCR languages (e.g., 'all', 'eng', 'eng+ara')"
5680 echo " -h Show this help message, then exit"
5781 echo " Example:"
5882 echo " OCR4Linux.sh -d $HOME /screenshots -l"
5983 echo " OCR4Linux.sh --lang eng+ara"
6084 echo " OCR4Linux.sh --lang all -l"
85+ echo " OCR4Linux.sh -u"
86+ echo " OCR4Linux.sh --update"
6187 echo " OCR4Linux.sh -h"
6288 echo " Note:"
6389 echo " - If --lang is not specified, an interactive language selection menu will appear"
6490 echo " - Use 'all' to select all available languages"
6591 echo " - Use '+' to separate multiple languages (e.g., 'eng+ara+fra')"
6692 echo " - Without arguments, screenshots are saved to $SCREENSHOT_DIRECTORY "
93+ echo " - The -u or --update option gives instructions on how to update OCR4Linux."
6794}
6895
6996# Parse command line arguments
@@ -81,6 +108,10 @@ while [[ $# -gt 0 ]]; do
81108 KEEP_LOGS=true
82109 shift
83110 ;;
111+ -u|--update)
112+ perform_update
113+ exit 0
114+ ;;
84115 --lang)
85116 SPECIFIED_LANGS=" $2 "
86117 LANG_SPECIFIED=true
@@ -98,18 +129,6 @@ while [[ $# -gt 0 ]]; do
98129 esac
99130done
100131
101- # Add log function
102- log_message () {
103- local message
104- message=" [$( date ' +%Y-%m-%d %H:%M:%S' ) ] $1 "
105- echo " $message " >&2
106- if [ " $KEEP_LOGS " = true ]; then
107- {
108- echo " $message "
109- } >> " $OCR4Linux_HOME /$LOGS_FILE_NAME "
110- fi
111- }
112-
113132# Check if the required files exist.
114133check_if_files_exist () {
115134 log_message " Checking required files and directories..."
0 commit comments