Using DT as a remote print server

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



You could also set up a split VPN so that only traffic to your company is routed through the VPN. That requires setting special routes and is certainly not as cool as your nifty trick with DT.

Thanks! In my case it’s my employer’s computer and I can’t change the VPN settings (which would be a good workaround if I could).

Very cool use of tags and smart rule to get around a particularly tough situation. Well done !
I hope this not only helps others but also inspires them to consider how they could employ similar tactics in their environments. :heart: :slight_smile:

1 Like

Hopefully your boss doesn’t hang out here. Exfiltrating data via DT, a good survival tool, but maybe just the sort of thing those spoilsports in your IT department might want to mess with. Be vewwy vewwy quiet…