%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/share/cups/braille/
Upload File :
Create Path :
Current File : //usr/share/cups/braille/index.sh

#
# Copyright (c) 2015-2016, 2018 Samuel Thibault <samuel.thibault@ens-lyon.org>
# 
# Licensed under Apache License v2.0.  See the file "LICENSE" for more
# information.
# 

. /usr/share/cups/braille/cups-braille.sh

FIRMWARE=$(getOptionNumber IndexFirmwareVersion)
[ $? = 0 ] || exit 1
DUPLEX=$(getOption Duplex)
[ -n "$DUPLEX" ] || DUPLEX=None
ZFOLDING=$(getOption ZFolding)
[ -n "$ZFOLDING" ] || ZFOLDING=False
SIDEWAYS=$(getOption SideWays)
[ -n "$SIDEWAYS" ] || SIDEWAYS=False
SADDLESTITCH=$(getOption SaddleStitch)
[ -n "$SADDLESTITCH" ] || SADDLESTITCH=False
TABLE=$(getOptionNumber IndexTable)
[ $? = 0 ] || exit 1
MULTIPLEIMPACT=$(getOptionNumber IndexMultipleImpact)
[ $? = 0 ] || exit 1
HWPAGENUMBER=$(getOption HardwarePageNumber)

# Convert from 100th of mm to Inch fraction
mmToIndexIn () {
  # 100th of mm
  MM=$1

  # 120th of inches
  IN120=$(($MM * 12 / 254))

  # Integer part
  INT=$(($IN120 / 120 ))

  # Fractional part, first in 120th of inch
  FRAC=$(($IN120 % 120))

  # Convert to Index-specific values
  if [ $FRAC -lt 30 ];  then
    # Round down to zero
    FRAC=0
  elif [ $FRAC -ge 30 -a $FRAC -lt 40 ];  then
    # Round down to a quarter
    FRAC=1
  elif [ $FRAC -ge 40 -a $FRAC -lt 60 ];  then
    # Round down to a third
    FRAC=2
  elif [ $FRAC -ge 60 -a $FRAC -lt 80 ];  then
    # Round down to a half
    FRAC=3
  elif [ $FRAC -ge 80 -a $FRAC -lt 90 ];  then
    # Round down to two thirds
    FRAC=4
  else
    # Round down to three quarters
    FRAC=5
  fi

  echo $INT$FRAC
}

# Return options common to v3 and v4
commonOptions() {
  INIT=
  # Disable options we don't want: first line offset and page numbering
  INIT+=,FO0

  # Support hardware-assisted multiple copies
  if [ $NB != 1 ]
  then
    INIT+=,MC$NB
  fi

  INIT+=,MI$MULTIPLEIMPACT

  case "$DUPLEX" in
    None|DuplexNoTumble) ;;
    *) printf "ERROR: duplex mode %s is not supported\n" "$DUPLEX" >&2 ; exit 1;;
  esac

  case "$DUPLEX,$ZFOLDING,$SADDLESTITCH,$SIDEWAYS" in
    None,False,False,False)           INIT+=,DP1 ;; # Single Sided
    DuplexNoTumble,False,False,False) INIT+=,DP2 ;; # Double Sided

    DuplexNoTumble,True,False,False)  INIT+=,DP3 ;; # Double Sided z-folding
    None,True,False,False)            INIT+=,DP5 ;; # Single Sided z-folding

    DuplexNoTumble,False,True,False)  INIT+=,DP4 ;; # Double Sided Saddle Stitch
    None,False,True,False)            INIT+=,DP8 ;; # Single Sided Saddle Stitch

    DuplexNoTumble,True,False,True)   INIT+=,DP6 ;; # Double Sided z-folding sideways
    None,True,False,True)             INIT+=,DP7 ;; # Single Sided z-folding sideways

    *) printf "ERROR: unsupported page folding: duplex=%s z-folding=%s sideways=%s saddlestich=%s\n" "$DUPLEX" "$ZFOLDING" "$SIDEWAYS" "$SADDLESTITCH" >&2 ; exit 1 ;;
  esac

  # Configure dots spacing
  case "$TEXTDOTDISTANCE" in
    220) INIT+=,TD1 ;;
    250) INIT+=,TD0 ;;
    320) INIT+=,TD2 ;;
    *)   printf "ERROR: unsupported '%s' text dot distance\n" "$TEXTDOTDISTANCE" >&2 ; exit 1 ;;
  esac
  case "$GRAPHICDOTDISTANCE" in
    160) INIT+=,GD2 ;;
    200) INIT+=,GD0 ;;
    250) INIT+=,GD1 ;;
    *)   printf "ERROR: unsupported '%s' graphic dot distance\n" "$GRAPHICDOTDISTANCE" >&2 ; exit 1 ;;
  esac

  # Currently unused, implemented in software
  case "$HWPAGENUMBER" in
    None|'')     INIT+=,PN0 ;;
    Top)         INIT+=,PN1 ;;
    TopLeft)     INIT+=,PN2 ;;
    TopRight)    INIT+=,PN3 ;;
    Bottom)      INIT+=,PN4 ;;
    BottomLeft)  INIT+=,PN5 ;;
    BottomRight) INIT+=,PN6 ;;
    *)   printf "ERROR: unsupported %s page number\n" "$HWPAGENUMBER" >&2 ; exit 1 ;;
  esac

  echo "$INIT"
}

Zerion Mini Shell 1.0