Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a wireless printer which is always on, and an always on fanless Linux server.

Looking at the mprinter project on Kickstarter I started to wonder if there is a way for me to prepare an automated daily printout based on some settings.

Things to be printed could include

  • weather forecast for my locations
  • TODOs scheduled for that day
  • a "quote of a day" or "word of the day"
  • stats from Google Analytics for my site
  • and many more …

I would set a printout at 6:15 every work day so its on my printer when I am already up, having a coffee.

While I know this can be done by combining the power of TeX, cron and a script language to manage the dynamic part of the PDF, I believe this is a use case someone might have already addressed.

How could I set that up?

share|improve this question
    
@terdon Please don't take that rule too stricly. There is a specific task to solve here, and it's not a question in the vein of "Suggest me the best XYZ". –  slhck Sep 21 '12 at 14:27

1 Answer 1

By no means is this the cleanest way of doing things. This is a general idea of what you could quickly hack together to achieve what you want to do.

Set up your printer

First and foremost, you want to get your printer working. CUPS does support wireless printers, so with a bit of luck and the right drivers you will be able to set that up. Refer to your server's distribution wiki / help pages for more information.

Get the data

You then want to get your data in plaintext. Google will help you find scripts that will do most the generic of the tasks that you need:

For other specific needs, you'll have to write them on your own:

  • TODOs depend on what mechanism you already use to keep track of that
  • Google Analytics. Unfortunately not accessible via command line browsers and I don't know anything about the Google Analytics API. I can only think of very ugly and unreliable ways of doing this so you will have to do some searching.

Hack your scripts together

We now have a bunch of scripts that work, but we need to put all that data together. For most of my hackjobs I go with Python. Not only is it easy to pick up and use, you can even "embed" other scripts into it a python file and grab their input:

from os import popen

script='''ps aux; echo; free -h'''

output=popen(script).read()

Not the best idea, but this way you don't have to re-write complex functions that are already available to you.

Formatting

HTML is easy to learn and prettify. Google to the rescue again: Python and HTML. Join the data we have with HTML, add a few lines of CSS to define what your page will look like (fonts, colors, layouts etc) and have python write all this into a file.

Print your document

  1. Save your script on your server and test it out. Jump to Can I print html files from the command-line? to do some test printing.

  2. Add a cronjob that will run your script every morning at the desired time.

  3. Add coffee.

Paper is a precious resource; I would have my webserver serve this file and read it on my tablet, phone, or laptop.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.