lprshell 2.4 KB

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