Printers :: Lua printer question



I have installed DSL 4.2.5 on my HD, I have wifi working, sound working and printing working. My question concerns "Lua". I placed it's icon on my desktop (it's linked to /usr/local/bin/printing.lua) when I drop a text file on it nothing happens. As I said before printing is working from app menus (Ted,Firefox, etc...). My printer is a network printer that was configured via Apsfilter (gimp 4.x) and works great.
Any ideas? Thanks!

Likely that I used the Apsfilter default printer name of "lp" and yours is not.

/usr/local/bin/printing.lua is a script that I use everyday. If you can print from the command line then you can drag-n-drop text or postscript files to print. I always print to file from each application. Then when I am ready to actually print, I drag the .txt or .ps onto the printing desktop icon.

I suggest to look at the script and look at the second to last line.
Code Sample

#!/bin/lua
-- (c) 2007 Robert Shingledecker
-- Lua script to support printing via dfm printing icon.

function checkPrintcap()
  printcap,err = io.popen("ls -s /opt/printcap|awk '{print $1}'")
  printcapSize = printcap:read("*l")
  printcap:close()
  return printcapSize
end

if checkPrintcap() == "0" then
  response = fltk.fl_choice("No printer found!\nSetup Printer Now?","No","Yes",NULL)
  if response == 1 then
     os.execute('aterm -T "apsfilter" -e sudo /usr/share/apsfilter/SETUP')
     if checkPrintcap() == "0" then
        os.exit(1)
     else
        os.execute('touch /tmp/printer.flag')
     end
  else
     os.exit(1)
  end
end

lprTest = io.popen("ps | grep lpd | grep -v 'grep lpd'")
lprCheck = lprTest:read("*l")
lprTest:close()
if lprCheck == nil then
  print("Starting lpd...")
  os.execute("sudo /usr/sbin/lpd")
end
if #arg == 1 then
  os.execute("lpr -h -Plp "..arg[1])
end


Change the os.execute to your specific needs.

Thanks for your quick reply.
I edited in my printer's name and it works great.
Thank You!

I wonder if checking for the PRINTER env var would be useful? (and use something like os.getenv I suppose)
Is it only the printer name that differs for a:

1. Unix network printer?
2. A USB printer?
3. A samba printer?

I write script using mainly defaults (parallell and lp) especially when I do not own or cannot setup all supported situations.

Perhaps those who use apsfilter in each supported protocol/printer style can post or verify that only a printer name is variable. It is of course then easy to implement an environment variable. However by default setup of apsfilter no such environment variable is created.

Next Page...
original here.