home *** CD-ROM | disk | FTP | other *** search
/ PCNET 2006 September - Disc 1 / PCNET_CD_2006_09.iso / linux / puppy-barebones-2.01r2.iso / pup_201.sfs / usr / bin / lprshell < prev    next >
Encoding:
Text File  |  2005-10-23  |  2.4 KB  |  100 lines

  1. #!/bin/sh
  2.  
  3.  
  4. #note, using a patched version of abiword 2.2.7 with filetype override on commandline.
  5. # --useextension=.txt
  6.  
  7. #v1.0.6
  8. #abiword-2.4.1 has --import-extension, but it doesn't work.
  9. #so, for now, using nenscript...
  10.  
  11. PAPERSIZE="`cat /etc/pdq/printrc|grep "driver_args"|head -n 1|cut -f 2 -d '='|tr -d '}'|tr -d '"'|tr -d ' '`"
  12.  
  13. #v1.0.3
  14. #if the nenscript pkg installed, assume no other way to convert text file to postscript...
  15. NENPAPER="A4"
  16. if [ "$PAPERSIZE" = "letter" ];then
  17.  NENPAPER="US"
  18. fi
  19. if [ -f /usr/sbin/nenscript ];then
  20.  if [ "$1" ];then
  21.   file -b $1 | grep -i "postscript"
  22.  else #to handle piped input.
  23.   false
  24.  fi
  25.  if [ $? -eq 0 ];then
  26.   lpr $1
  27.  else
  28.   if [ "$1" ];then
  29.    PSFILE="`basename $1`"
  30.   else
  31.    PSFILE="tempprintfile"
  32.   fi
  33.   #note, if no $1 then nenscript accepts stdin...
  34.   /usr/sbin/nenscript -p/tmp/$PSFILE.ps -T${NENPAPER} ${1}
  35.   sync
  36.   lpr /tmp/$PSFILE.ps
  37.  fi
  38.  exit
  39. fi
  40.  
  41. TEXTFILE="`basename $1`"
  42. PATHFILE="$1"
  43.  
  44. PRINFO="INFORMATION:
  45. This application is using /usr/bin/lprshell to convert
  46. the file to Postscript prior to sending it to lpr.
  47. In the case of plain text, ABW, DOC and RTF files, 
  48. Abiword is used as the filter. Abiword can be invoked from
  49. the commandline to convert these formats to Postscript.
  50.  
  51. Note that lpr is a symlink to pdq, which will call
  52. gs (Ghostscript) to print the file.
  53. After a short delay, your file should print.
  54. If it does not, did you run the Puppy Printer Wizard?
  55. Then, did you run XPDQ and choose the printer as the
  56. default printer?"
  57. xmessage -timeout 120 -bg "#ff00ff" -title "lprshell information" -buttons "" "$PRINFO" &
  58.  
  59. EXTRATXT=""
  60. OVERRIDEOPTION=""
  61. file -b $1 | grep -i "postscript"
  62. if [ $? -eq 0 ];then
  63.  cp -af $1 /tmp/$TEXTFILE
  64. else
  65.  
  66.  echo "$TEXTFILE" | grep -i ".txt"
  67.  if [ ! $? -eq 0 ];then
  68.   echo "$TEXTFILE" | grep -i ".rtf"
  69.   if [ ! $? -eq 0 ];then
  70.    echo "$TEXTFILE" | grep -i ".doc"
  71.    if [ ! $? -eq 0 ];then
  72.     echo "$TEXTFILE" | grep -i ".abw"
  73.     if [ ! $? -eq 0 ];then
  74.      #treat file as plain text...
  75.      cp -af $1 $1.txt
  76.      PATHFILE="$1.txt"
  77.      EXTRATXT="yes"
  78.      OVERRIDEOPTION='--useextension=.txt'
  79.     fi
  80.    fi
  81.   fi
  82.  else
  83.   OVERRIDEOPTION='--useextension=.txt'
  84.  fi
  85.  
  86.  #Ted ++printToFilePaper $PATHFILE /tmp/$TEXTFILE.ps $PAPERSIZE
  87.  abiword --print=/tmp/$TEXTFILE.ps $OVERRIDEOPTION $PATHFILE
  88.  TEXTFILE="$TEXTFILE.ps"
  89.  if [ "$EXTRATXT" = "yes" ];then
  90.   rm -f $1.txt
  91.  fi
  92. fi
  93.  
  94. sync
  95. sleep 2
  96. lpr /tmp/$TEXTFILE
  97.  
  98. #rm -f /tmp/$TEXTFILE
  99. #killall xmessage
  100.