~xubuntu-dev/xubuntu-default-settings/trunk

« back to all changes in this revision

Viewing changes to usr/bin/thunar-print

* Add new custom action for Thunar to "Print file/s", affected/new files:
  - usr/bin/thunar-print
  - etc/xdg/xdg-xubuntu/Thunar/uca.xml.in

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env bash
 
2
 
 
3
# Authors: Simon Steinbeiß <simon@xfce.org>
 
4
#          Florian Schüller <florian.schueller@gmail.com>
 
5
 
 
6
IFS=$(echo -en "\n\b")
 
7
 
 
8
for File in "$@"
 
9
do
 
10
  # just some incomplete useability hints for possible errors
 
11
  case ${File,,} in
 
12
    # The list of extensions is based on the LibreOffice Mimetype List, adding some that were missing (e.g. .rtf):
 
13
    # LIBREOFFICE_MIME_FILE=/usr/share/mime-info/libreoffice.mime
 
14
    *.doc|*.docm|*.docx|*.dotm|*.dotx|*.fodg|*.fodp|*.fods|*.fodt|*.odb|*.odf|*.odg|*.odm|*.odp|*.ods|*.odt|*.otg|*.oth|*.otp|*.ots|*.ott|*.potm|*.potx|*.ppt|*.pptm|*.pptx|*.rtf|*.xls|*.xlsb|*.xlsm|*.xlsx|*.xltm|*.xltx)
 
15
      # either libreoffice call failed or $LIBREOFFICE_MIME_FILE is missing
 
16
      if [ -x "$(command -v libreoffice)" ]; then
 
17
        libreoffice --nologo -p "$File"
 
18
      else
 
19
        notify-send "Printing $File failed" "LibreOffice does not seem to be installed." -i document-print
 
20
      fi;
 
21
      ;;
 
22
    *.xcf)
 
23
      if [ -x "$(command -v gimp)" ]; then
 
24
        gimp --no-interface --new-instance --batch="(file-print-gtk 0 (car (gimp-file-load 1 \"$File\" \"$File\")))" --batch="(gimp-quit 1)"
 
25
      else
 
26
        notify-send "Printing $File failed" "Gimp does not seem to be installed." -i document-print
 
27
      fi;
 
28
      ;;
 
29
    *.svg)
 
30
      if [ -x "$(command -v inkscape)" ]; then
 
31
        inkscape --without-gui --export-pdf=/dev/stdout "$File"| lpr
 
32
      else
 
33
        notify-send "Printing $File failed" "Inkscape does not seem to be installed." -i document-print
 
34
      fi;
 
35
      ;;
 
36
    # The CUPS extensions are based on the CUPS_FILTER_FILE
 
37
    # CUPS_FILTER_FILE=/usr/share/cups/mime/cupsfilters.convs
 
38
    *.asc|*.brf|*.css|*.gif|*.htm|*.html|*.jpe|*.jpeg|*.jpg|*.pbm|*.pdf|*.pgm|*.png|*.pnm|*.pot|*.ppm|*.shtml|*.srt|*.text|*.tif|*.tiff|*.txt|*.xbm|*.xpm|*.xwd)
 
39
      if [ -x "$(command -v lpr)" ]; then
 
40
        lpr "$File"
 
41
      else
 
42
        notify-send "Printing $File failed" "CUPS does not seem to be installed." -i document-print
 
43
      fi;
 
44
      ;;
 
45
    *)
 
46
      notify-send "Printing $File failed" "The File $File cannot be printed directly." -i document-print
 
47
      ;;
 
48
  esac
 
49
done
 
50
 
 
51
exit 0