From 070947073d057b54f428e06c68420ec86749dabe Mon Sep 17 00:00:00 2001
From: Martin Mares <mj@ucw.cz>
Date: Mon, 31 May 2021 15:39:28 +0200
Subject: [PATCH] Added texttopdf-auto filter

---
 Makefile                   |  2 +-
 debian/changelog           |  6 ++++++
 debian/control             |  2 +-
 filters/Makefile           | 10 ++++++++++
 filters/kam-printing.convs |  8 ++++++++
 filters/texttopdf-auto     | 14 ++++++++++++++
 6 files changed, 40 insertions(+), 2 deletions(-)
 create mode 100644 filters/Makefile
 create mode 100644 filters/kam-printing.convs
 create mode 100755 filters/texttopdf-auto

diff --git a/Makefile b/Makefile
index e1491bb..0610e0e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-SUBDIRS=xerox-acct xerox-xcpt
+SUBDIRS=filters xerox-acct xerox-xcpt
 .DEFAULT_GOAL := all
 
 all clean install:
diff --git a/debian/changelog b/debian/changelog
index 7225711..6e67435 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+kam-printing (0.2) unstable; urgency=medium
+
+  * Added texttopdf-auto.
+
+ -- Martin Mares <mj@ucw.cz>  Mon, 31 May 2021 15:35:25 +0200
+
 kam-printing (0.1) unstable; urgency=medium
 
   * Initial release.
diff --git a/debian/control b/debian/control
index 277c339..5f3f1ef 100644
--- a/debian/control
+++ b/debian/control
@@ -8,6 +8,6 @@ Vcs-Git: https://gitlab.kam.mff.cuni.cz/wizards/kam-printing
 
 Package: kam-printing
 Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}
+Depends: ${shlibs:Depends}, ${misc:Depends}, enca
 Description: KAM printer drivers
  Printer drivers we use at KAM.
diff --git a/filters/Makefile b/filters/Makefile
new file mode 100644
index 0000000..12fc961
--- /dev/null
+++ b/filters/Makefile
@@ -0,0 +1,10 @@
+all:
+
+clean:
+
+install: all
+	install -d $(DESTDIR)/usr/lib/cups/filter $(DESTDIR)/usr/share/cups/mime
+	install -m 755 texttopdf-auto $(DESTDIR)/usr/lib/cups/filter/
+	install -m 644 kam-printing.convs $(DESTDIR)/usr/share/cups/mime/
+
+.PHONY: all clean install
diff --git a/filters/kam-printing.convs b/filters/kam-printing.convs
new file mode 100644
index 0000000..c7405cd
--- /dev/null
+++ b/filters/kam-printing.convs
@@ -0,0 +1,8 @@
+# Override conversions which originally used texttopdf (default cost = 32)
+
+application/x-cshell	application/pdf				31	texttopdf-auto
+application/x-csource	application/pdf				31	texttopdf-auto
+application/x-perl	application/pdf				31	texttopdf-auto
+application/x-shell	application/pdf				31	texttopdf-auto
+text/plain		application/pdf				31	texttopdf-auto
+text/html		application/pdf				31	texttopdf-auto
diff --git a/filters/texttopdf-auto b/filters/texttopdf-auto
new file mode 100755
index 0000000..95cc00b
--- /dev/null
+++ b/filters/texttopdf-auto
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+if [ $# == 0 ]; then
+  echo >&2 "ERROR: $0 job-id user title copies options [file]"
+  exit 1
+fi
+
+{ if [ $# -ge 6 ]; then
+    cat $6
+  else
+    cat
+  fi; } |
+    enconv -x utf-8 -L czech |
+    /usr/lib/cups/filter/texttopdf "${@:1:5}"
-- 
GitLab