#! /bin/bash SCANNER=`sane-find-scanner -q | sed -e 's/.*at /snapscan:/'` # TMPFILE="/tmp/scan.tiff" # LOCKFILE="/tmp/copy.lock" # # # , if ! lockfile-create --retry 2 -l $LOCKFILE; then exit fi scanimage --device-name $SCANNER --format tiff --mode Gray -x 210 -y 297 --resolution 300 --brightness -3 -p > $TMPFILE #. man scanimage tiff2ps -z -w 8.27 -h 11.69 $TMPFILE | lp lockfile-remove -l $LOCKFILE #
SCANNER=`sane-find-scanner -q | sed -e 's/.*at /snapscan:/'` # DIALOG=zenity TMPFILE="/tmp/scan.tiff" # LOCKFILE="/tmp/copy.lock" # DLG_COUNT_TITLE=" " DLG_COUNT_TEXT=" " DLG_PROGRESS_TITLE=" " DLG_PROGRESS_TEXT="..." MSG_START_PROCESS=" $SCANNER" MSG_SCAN="" MSG_PRINT=" " MSG_COMPLETE=" ." MSG_ERROR_LOCK=": , ." MSG_ERROR_SCAN=": , ." MSG_ERROR_PRINT=": ."
COPY_COUNT=`$DIALOG --scale\ --title="$DLG_COUNT_TITLE"\ --text="$DLG_COUNT_TEXT"\ --min-value=1\ --max-value=50\ --value=1\ --step=1`
if [[ "$?" == "0" ]]; then # fi
--progress
. As a result, the previous code takes the form: if [[ "$?" == "0" ]]; then ( # ) | $DIALOG --progress \ --title="$DLG_PROGRESS_TITLE" \ --text="$DLG_PROGRESS_TEXT" \ --percentage=0 --auto-close fi
echo 10
sets the progress bar to 10%, echo 100
to 100%. To indicate at what stage of the process we are (scanning, printing or completing the program) in the form of text, you also need to use echo, but we must also add a hash sign at the beginning of the message, for example echo "# The scanning process is in progress" will cause the text to appear on the progress bar. #! /bin/bash SCANNER=`sane-find-scanner -q | sed -e 's/.*at /snapscan:/'` # DIALOG=zenity TMPFILE="/tmp/scan.tiff" # LOCKFILE="/tmp/copy.lock" # DLG_COUNT_TITLE=" " DLG_COUNT_TEXT=" " DLG_PROGRESS_TITLE=" " DLG_PROGRESS_TEXT="..." MSG_START_PROCESS=" $SCANNER" MSG_SCAN="" MSG_PRINT=" " MSG_COMPLETE=" ." MSG_ERROR_LOCK=": , ." MSG_ERROR_SCAN=": , ." MSG_ERROR_PRINT=": ." # if ! lockfile-create --retry 2 -l $LOCKFILE; then $DIALOG --error --text "$MSG_ERROR_LOCK" exit fi COPY_COUNT=`$DIALOG --scale\ --title="$DLG_COUNT_TITLE"\ --text="$DLG_COUNT_TEXT"\ --min-value=1\ --max-value=50\ --value=1\ --step=1` if [[ "$?" == "0" ]]; then ( echo "# $MSG_START_PROCESS" echo "10" sleep 2 echo "# $MSG_SCAN" echo "25" #. man scanimage scanimage --device-name $SCANNER\ --format tiff\ --mode Gray\ -x 210 -y 297 --resolution 300\ --brightness -3 > $TMPFILE if [ $? != 0 ]; then $DIALOG --error --text "$MSG_ERROR_SCAN" lockfile-remove -l $LOCKFILE exit fi echo "# $MSG_PRINT" echo "75" # if [[ "$COPY_COUNT" == "1" ]]; then tiff2ps -z -w 8.27 -h 11.69 $TMPFILE | lp else tiff2ps -z -w 8.27 -h 11.69 $TMPFILE | lp -n $COPY_COUNT fi if [ $? != 0 ]; then $DIALOG --error --text "$MSG_ERROR_PRINT" lockfile-remove -l $LOCKFILE exit fi rm -f $TMPFILE echo "# $MSG_COMPLETE" echo "100" sleep 2 ) | $DIALOG --progress\ --title="$DLG_PROGRESS_TITLE"\ --text="$DLG_PROGRESS_TEXT"\ --percentage=0\ --auto-close || lockfile-remove -l $LOCKFILE fi lockfile-remove -l $LOCKFILE
Source: https://habr.com/ru/post/156807/
All Articles