Some non-GoboLinux scripts

Having already posted some GoboLinux-specific scripts, this time I’ll do some of the others I find useful that aren’t tied to a particular distribution.

  • lpr is a replacement for the lpr provided by CUPS or otherwise that prints to a PDF. It’s useful for working on a laptop that may not have a printer available directly all the time, or for making PDF exports from programs that don’t provide that directly. My principal use for it is printing to a PDF to be taken on a flash drive to a system that does have a printer attached, and to save a copy of something I may want to print a duplicate of at a different place or time.

    It’s a fairly simple script. It allows you to specify a mountpoint for your flash drive (NFS share, SSHFS, …), where the generated PDF will be put. If the mountpoint doesn’t exist, the file goes into /tmp, so it works for transient mounts as well. Generated filenames are of the form ‘YYYYMMDDHHMMSS.pdf’. The script depends on ps2pdf13 being available – substitute another version or plain ps2pdf if you want (it’s part of Ghostscript). It also calls a script called “notify” to display a message informing you of the print and what it’s called: it’s optional, so you can delete that line if you want, but it works with the script I’m going to post below.

  • notify is that script. This version uses knotify, so it requires you to be running KDE. It takes two parameters: the first gives the title of the transient message displayed, and the second its content. An alternative version takes the whole argument list as the message content. This one’s mostly useful for calling from other scripts. Change the “16 0 1″ parameters at the end to get different behaviour out of knotify.
  • xri resolves an XRI/i-name to a URI, using the xri.net resolver, and outputs the final URI after following all redirects. Usage is simple, for example: xri @example/+blog – if there’s no global specifier present, it assumes a personal i-name, so xri mwh will work, if you’re using a shell where “=mwh” is a path lookup. How useful this is depends on how often you deal with i-names and what you’re wanting to do with them. I still find them a little dubious myself, but the contact service is nice when I’m posting scripts like this and don’t want to put my email address out to be harvested, and they do seem well-intentioned, so I guess we’ll see how they go. But that discussion’s for another day.

    This script depends on curl, but could be adapted to work fairly easily with anything able to make a HEAD request (wget is difficult, since it always follows Location: headers, but anything better-behaved would work).

  • twitter sends twitter messages (!). All the parameters on the command line are used for the message, so twitter This is a tweet will send “This is a tweet”. The first time you run it, you’ll be prompted for your twitter username/email address and password to use. They are saved into ~/.twitter if you want to change them later (it’s sourced as a bash script, so edit accordingly, or just delete it and you’ll be prompted again next time). This one also depends on curl, but adapting it to use wget –post-data= would be pretty trivial. The URL-encoding used is a little excessive, and %-encodes every character, so if somebody can come up with an equally concise method that doesn’t I’ll update the script. It is legal (and works) as it is, but it’s not very clean to have things like “%54%68%69%73%20%69%73%20%61%20%74%77%65%65%74″ go through the wire unnecessarily.

As last time, I’m posting these scripts in the hope that they will be useful, but without any warranty that they’ll work or not break things. They’re available under the GPLv3+, and any improvements anybody makes to them will be welcome if sent to me. If anybody wants them relicensed for some reason, be in touch too and I’ll consider it.

Leave a Reply