On Commanding LinesTue Jun 19, 2012
Still working away on the authentication system. I'm basically at the point where I can use RSA keys to sign in to my demo webapp. On one browser. As long as the keys are in PEM format. And
crypto:verify is in a good mood.
This isn't about that though.
I've been slowly moving towards more and more command-line oriented interfaces. It's not a recent trend, in fact it started pretty much when I first discovered Emacs. Ever since doing away with my desktop environment a little while ago, it's been more of a necessity than idle speculation. The good news is that there's almost nothing I wanted to do in X windows that I can't do via command line.
Command Line MVPs
Let me draw your attention to some command line programs that I honestly wouldn't want to go without anymore. Not counting obvious necessities like
I've already written a bit about wicd-curses, the very good, simple command line network manager. After you set up a wireless device with
Shift+p, and set up your connection keys, it'll make sure you're as plugged in as you can possibly be with no need for a network widget. You don't even need to run it unless you're connecting to a new network; the daemon starts up with the rest of your machine.
htop isn't anything new, if you've been paying attention. It's an improvement over the regular top in that it gives you more information and prettier colors. That's reason enough for me to use it.
acpi does quite a few things relating to cooling, power, and battery. Really, I just use it as the replacement for the gnome/xfce battery widget.
screen is something I've been using forever. My first time firing it up was to deploy a Hunchentoot application. Since then, I've used it as a way of managing multiple terminals, and kicked its tires as a full-on window manager.
mplayer is another piece that I've been using for a long time. Even while bumping around GNOME, I preferred this to VLC (YMMV). It's worth a read through the documentation if you're having a slow day; the program does various crazy things in addition to music/video playback, including bitmap frame outputs, format conversion and some timeline-based edits.
pacpl is an audio chopping tool. As of the latest version in the Debian repos, it can directly extract music from videos. As you can see by the website there, it can convert to and from pretty much any audio format you care to name, though I mostly use it to convert things to oggs.
imagemagick is a command-line image chopping program with so many options that you'd really better just read the docs. It's actually composed of a bunch of different utilities, of which I mostly use
getflashvideos is about the only way I get to see most videos, given a) how crappy flash support is when you're even half-way dedicated to the idea of Free software and b) how few sites other than YouTube provide an HTML5 based video player.
transmission-cli is the command line interface to my favorite torrent client. Granted, I don't torrent much since I got out of the habit of downloading the massive install CDs, but still.
gtypist is a curses-based typing tutor that has effectively replaced klavaro for me. It's mildly more entertaining to run typing drills on surrealist, minimal poetry than it is to type out old newspaper articles. The only thing about it that rustles my jimmies is that it enforces hitting space twice after a period. Which is a thing I guess? Honestly it sounds like an anachronistic behavior that used to make sense back when actual humans used actual typewriters. Luckily, the lessons are contained in a set of conf files, so I'll be able to do something about this.
EDIT: Aaaaand bam. Enjoy.
Wed, 20 Jun, 2012
canto is a command-line based RSS feed reader. I complained about liferea earlier for its complexity, and having taken a look at a number of feed readers (both GUI and CLI), that doesn't seem to be an uncommon feature.
canto, by contrast is ridiculously simple; set up your
conf file, and it'll track those feeds, pulling when you tell it to (every 5 minutes by default). The example config up at the project site is pretty extensive, but I've gotten on fine with a much more minimal setup:
from canto.extra import * import os link_handler("lynx \"%u\"", text=True) image_handler("feh \"%u\"", fetch=True) keys['y'] = yank ## requires xclip filters=[show_unread, None] add("http://www.groklaw.net/backend/GrokLaw.rss") add("http://stackexchange.com/feeds/tagsets/43442/inaimathi-lang-digests?sort=active") add("http://www.antipope.org/charlie/blog-static/atom.xml") add("http://rss.slashdot.org/slashdot/Slashdot") add("http://kerneltrap.org/node/feed")
The one quirk that I have to highlight is that by default, its
update doesn't fetch, it just updates from the local pool. In order to fetch, you actually need to run
canto-fetch somehow. You can throw it in your
crontab, but given how I use an RSS reader, it made more sense for me to just bind that to a StumpWM key.
feh is an extremely lightweight command-line imageviewer with options to browse folders, delete files, do slideshows and other assorted goodness. I didn't find this looking for an imageviewer, I found it looking for a way to get a background picture directly in Stump. It turns out that this does it:
(defun set-background (bg-image) (run-shell-command (format nil "feh --bg-scale ~a" bg-image)))
lynx is something I don't use on a regular basis anymore, but it is quite useful when I need to check a discussion or two without booting up X. It happens every once in a while.
Command Line Gaps
There aren't as many as you'd think. In fact, for my purposes, there is exactly one, and it's sort of minor; the lack of good animated gif viewer. There is a concerted effort at putting one together, but it didn't exactly blow me away.
mplayer does a half-decent job, but chops when looping and doesn't loop by default (which is sort of helpful when describing haters).
feh is awesome for stills, but doesn't display gifs in an animated fashion, and neither does Emacs. At the moment, my workaround is to just use chromium and call it a day.
Ok, so maybe I lied a little in the previous section. The thing I really don't like about some command line programs is their sometimes inscrutable option settings and lack of sensible defaults.
That second one bugged me enough that I whipped up a pair of Ruby scripts to help me out with archiving a little while ago. Yesterday, I ported them to Python; what they do, basically, is provide a sane set of default options for creating and decompressing various archives. Instead of
tar -xyzomgwtfbbq foo.tgz, I can just call
pack -t tar.gz foo/ similarly replaces
tar -cwhyareyoueventryingtoreadthis foo.tar.gz foo/. I guess I could have done what most of my friends do (memorize the one or two most common combinations and call it a day), but having the machine adapt to humanware seems like the better idea to me.
That's also what caused me to sit down earlier and whip up a first draft at my first curses)-based program. I was trying to pull out sections of some movies into animated gifs, and using
convert manually proved to be laborious and repetitive. So, I did this.
I call it with a movie file, and the filename I want the result saved to. The program uses a curses interface to
- lets me pick a part of the movie to pull, using
mplayeroutput the chosen section as a series of JPGs in a temp folder
- opens the folder with
feh, giving me the opportunity to delete some frames as desired
- once I quit out of
feh, stitches the remaining frames together into an animated gif
Honestly, I'm not sure how often I'll want to do that again, but hey. I've got the process formalized now, so it should be Pie next time. And, now I know how to curse in Python.