Merge lp:~ochosi/xubuntu-default-settings/thunar-uca-print into lp:~xubuntu-dev/xubuntu-default-settings/trunk

Proposed by Simon Steinbeiß
Status: Merged
Merged at revision: 663
Proposed branch: lp:~ochosi/xubuntu-default-settings/thunar-uca-print
Merge into: lp:~xubuntu-dev/xubuntu-default-settings/trunk
Diff against target: 129 lines (+86/-1) (has conflicts)
5 files modified
debian/changelog (+4/-0)
debian/copyright (+2/-1)
debian/thunar-print-generate-mimetype-list.sh (+20/-0)
etc/xdg/xdg-xubuntu/Thunar/uca.xml.in (+9/-0)
usr/bin/thunar-print (+51/-0)
Conflict adding file usr/bin.  Moved existing file to usr/bin.moved.
To merge this branch: bzr merge lp:~ochosi/xubuntu-default-settings/thunar-uca-print
Reviewer Review Type Date Requested Status
Sean Davis Approve
Unit 193 Pending
Review via email: mp+340058@code.launchpad.net

Description of the change

Add a custom action for file printing to Thunar.

This script tries to be (a little) intelligent by checking if the corresponding tools are installed and by getting the file extension patterns based on CUPS capabilities and LO mime types.

To post a comment you must log in.
653. By Simon Steinbeiß

Add author information to thunar scripts

Revision history for this message
Unit 193 (unit193) wrote :

Can you also note the cleaning of whitespace in prior changelog entries? One comment inline.

654. By Simon Steinbeiß

Switch from mimetype-matching back to extensions

Unfortunately mimetypes are not consistent, so we have to
fall back to extensions.

655. By Simon Steinbeiß

Update patterns to match thunar-print script

656. By Simon Steinbeiß

Fix small issue in thunar-print extension script

657. By Simon Steinbeiß

Note cleaning of whitespace from changelog

658. By Simon Steinbeiß

thunar-pring: Check for CUPS and send a notification if it's not installed

Revision history for this message
Sean Davis (bluesabre) wrote :

Looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2018-03-02 03:04:42 +0000
3+++ debian/changelog 2018-03-02 23:03:10 +0000
4@@ -32,6 +32,10 @@
5 * etc/xdg/xdg-xubuntu/xfce4/xfconf/xfce-perchannel-xml/xfwm4.xml:
6 - Disable the alt-tab window previews by default, which make it
7 hard to identify and navigate between windows.
8+ * Add new custom action for Thunar to "Print file/s", affected/new files:
9+ - usr/bin/thunar-print
10+ - etc/xdg/xdg-xubuntu/Thunar/uca.xml.in
11+ * Drop superfluous whitespaces from changelog
12
13 [ Sean Davis ]
14 * etc/xdg/xdg-xubuntu/xfce4/xfconf/xfce-perchannel-xml/xfce4-power-manager.xml:
15
16=== modified file 'debian/copyright'
17--- debian/copyright 2017-08-30 00:47:59 +0000
18+++ debian/copyright 2018-03-02 23:03:10 +0000
19@@ -3,7 +3,8 @@
20 Upstream-Contact: Xubuntu Team <xubuntu-devel@lists.ubuntu.com>
21
22 Files: *
23-Copyright: 2013-2017, Sean Davis <bluesabre@ubuntu.com>
24+Copyright: 2013-2018, Sean Davis <bluesabre@ubuntu.com>
25+ 2013-2018, Simon Steinbeiß <simon@xfce.org>
26 2007-2011, Lionel Le Folgoc <mrpouit@ubuntu.com>
27 2007-2009, Cody A.W. Somerville <cody-somerville@ubuntu.com>
28 2006-2008, Gauvain Pocentek <gauvainpocentek@ubuntu.com>
29
30=== added file 'debian/thunar-print-generate-mimetype-list.sh'
31--- debian/thunar-print-generate-mimetype-list.sh 1970-01-01 00:00:00 +0000
32+++ debian/thunar-print-generate-mimetype-list.sh 2018-03-02 23:03:10 +0000
33@@ -0,0 +1,20 @@
34+#!/usr/bin/env bash
35+
36+# This simple script echoes all valid file extensions for the usr/bin/thunar-print
37+# custom action script.
38+# As capabilities of CUPS may differ, this script should ideally be run to populate the
39+# corresponding <patterns> node in etc/xdg/xdg-xubuntu/Thunar/uca.xml.in
40+# The contents of this node are currently hardcoded based on the output of this script.
41+
42+# Authors: Simon Steinbeiß <simon@xfce.org>
43+# Florian Schüller <florian.schueller@gmail.com>
44+
45+MIMETYPES=$(cat /usr/share/cups/mime/cupsfilters.convs|grep -Po "^[^#\t]+"|while read mime;do grep "^$mime" /etc/mime.types ;done|grep -Po "\t.*$")
46+LO_MIMETYPES=$(cat /usr/share/mime-info/libreoffice.mime|grep -Po "(?<=ext: ).*"|sort|uniq)
47+
48+for ext in $MIMETYPES $LO_MIMETYPES; do
49+ echo $ext;
50+done|sort|uniq|while read ext; do
51+ echo -n ",*.$ext";
52+done|tail -c +2
53+echo
54
55=== modified file 'etc/xdg/xdg-xubuntu/Thunar/uca.xml.in'
56--- etc/xdg/xdg-xubuntu/Thunar/uca.xml.in 2018-03-02 11:40:55 +0000
57+++ etc/xdg/xdg-xubuntu/Thunar/uca.xml.in 2018-03-02 23:03:10 +0000
58@@ -54,4 +54,13 @@
59 <directories/>
60 </action>
61
62+ <action>
63+ <icon>document-print</icon>
64+ <_name>Print file/s</_name>
65+ <command>thunar-print %F</command>
66+ <_description>Send one or multiple files to the default printer</_description>
67+ <patterns>*.asc,*.brf,*.css,*.doc,*.docm,*.docx,*.dotm,*.dotx,*.fodg,*.fodp,*.fods,*.fodt,*.gif,*.htm,*.html,*.jpe,*.jpeg,*.jpg,*.odb,*.odf,*.odg,*.odm,*.odp,*.ods,*.odt,*.otg,*.oth,*.otp,*.ots,*.ott,*.pbm,*.pdf,*.pgm,*.png,*.pnm,*.pot,*.potm,*.potx,*.ppm,*.ppt,*.pptm,*.pptx,*.rtf,*.shtml,*.srt,*.text,*.tif,*.tiff,*.txt,*.xbm,*.xls,*.xlsb,*.xlsm,*.xlsx,*.xltm,*.xltx,*.xpm,*.xwd</patterns>
68+ <directories/>
69+ </action>
70+
71 </actions>
72
73=== added directory 'usr/bin'
74=== renamed directory 'usr/bin' => 'usr/bin.moved'
75=== added file 'usr/bin/thunar-print'
76--- usr/bin/thunar-print 1970-01-01 00:00:00 +0000
77+++ usr/bin/thunar-print 2018-03-02 23:03:10 +0000
78@@ -0,0 +1,51 @@
79+#!/usr/bin/env bash
80+
81+# Authors: Simon Steinbeiß <simon@xfce.org>
82+# Florian Schüller <florian.schueller@gmail.com>
83+
84+IFS=$(echo -en "\n\b")
85+
86+for File in "$@"
87+do
88+ # just some incomplete useability hints for possible errors
89+ case ${File,,} in
90+ # The list of extensions is based on the LibreOffice Mimetype List, adding some that were missing (e.g. .rtf):
91+ # LIBREOFFICE_MIME_FILE=/usr/share/mime-info/libreoffice.mime
92+ *.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)
93+ # either libreoffice call failed or $LIBREOFFICE_MIME_FILE is missing
94+ if [ -x "$(command -v libreoffice)" ]; then
95+ libreoffice --nologo -p "$File"
96+ else
97+ notify-send "Printing $File failed" "LibreOffice does not seem to be installed." -i document-print
98+ fi;
99+ ;;
100+ *.xcf)
101+ if [ -x "$(command -v gimp)" ]; then
102+ gimp --no-interface --new-instance --batch="(file-print-gtk 0 (car (gimp-file-load 1 \"$File\" \"$File\")))" --batch="(gimp-quit 1)"
103+ else
104+ notify-send "Printing $File failed" "Gimp does not seem to be installed." -i document-print
105+ fi;
106+ ;;
107+ *.svg)
108+ if [ -x "$(command -v inkscape)" ]; then
109+ inkscape --without-gui --export-pdf=/dev/stdout "$File"| lpr
110+ else
111+ notify-send "Printing $File failed" "Inkscape does not seem to be installed." -i document-print
112+ fi;
113+ ;;
114+ # The CUPS extensions are based on the CUPS_FILTER_FILE
115+ # CUPS_FILTER_FILE=/usr/share/cups/mime/cupsfilters.convs
116+ *.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)
117+ if [ -x "$(command -v lpr)" ]; then
118+ lpr "$File"
119+ else
120+ notify-send "Printing $File failed" "CUPS does not seem to be installed." -i document-print
121+ fi;
122+ ;;
123+ *)
124+ notify-send "Printing $File failed" "The File $File cannot be printed directly." -i document-print
125+ ;;
126+ esac
127+done
128+
129+exit 0

Subscribers

People subscribed via source and target branches

to status/vote changes: