OK, this is an unusual usage of DT, but I wanted to pass it on.
When at home, I’m required to use a VPN to connect to my employer’s network. When I’m on the VPN, I can no longer access my local home network, including my printer. This is a common (and intrinsic) problem with VPNs. There are many possible workarounds, but none of them apply in my case. I usually disconnect the VPN, print, and then reconnect – which takes a few minutes.
But using DT3, I’ve put together a good workaround now that lets me print anything to my home network printer, even when on the VPN or not at home. Here’s what I do.
- To print a document (typically a PDF, but could be anything printable), I simply tag it with
print
, and add it to DT to the global Inbox. - Within a minute or two, DT syncs to my other systems, including one which is on my local home network and connected to the printer.
- I have a smart rule set up my home system, which runs after every sync. It identifies any documents tagged with
print,
and runs a short AppleScript to print them locally. - After printing, the file is renamed and flagged with
PRINTED
. I can delete or archive as needed.
Additional tags – such as duplex
, bw
, 2up
, 4up
, etc. allow for additional printing options, such as single/double-sided, color/mono, N-up, etc. The script parses these and generates the proper lpr
command.
This now lets me print a document from anywhere (including from my phone, or while away). There’s a delay of a minute or two to wait for the periodic sync, but that’s manageable – and perhaps a bonus, since it lets me kill a print job that I’ve sent in error.
I’m attaching the script and rule below – I hope it’s useful to someone.
# Print a DT item using 'lpr' to default printer.
#
# Allows optional tags for printing options:
# <duplex> -- print double-sided
# <2up>, <4up>, <9up> -- print n-up pages
# <bw> -- print monochrome
# NB: Proper flag for mono/color is printer-dependent.
# Search /etc/cups/ppd/<printername>.ppd for the right arguments,
# or see output of lpoptions -l
#
# Typically applied as a Smart Rule on items in the Inbox.
#
# Hankk 27-Nov-2021
on performSmartRule(theRecords)
tell application id "DNtp"
repeat with theRecord in theRecords
set thePath to path of theRecord
set theName to name of theRecord
set theTags to tags of theRecord
# Set the default paper size. Change this if desired.
set theCommand to "lpr -o media=A4 "
# Parse the tags
if theTags contains "duplex" then set theCommand to theCommand & " -o sides=two-sided-long-edge "
if theTags contains "bw" then set theCommand to theCommand & " -o BRMonoColor=Mono "
if theTags contains "2up" then set theCommand to theCommand & "-o number-up=2 "
if theTags contains "4up" then set theCommand to theCommand & "-o number-up=4 "
if theTags contains "9up" then set theCommand to theCommand & "-o number-up=9 "
set theFinalCommand to theCommand & " " & quoted form of thePath
# Execute the lpr command
do shell script (theFinalCommand)
end repeat
end tell
end performSmartRule