I do much of my programming on a laptop without a graphical environment
installed, and rarely ever type
startx on my desktop system. My console setup
is quite nice, and while it’s not for everyone, if you often find yourself
opening xterm windows to do most of your work, you might be interested in
dropping all that excess baggage and slimming down your system. There’s plenty
you can do in a terminal, so saddle up and get ready to give a big screw-you to
the overweight GPU-sucking graphical environments of the 21st century and take
a trip slightly back in time to back when things were text.
Many people, myself included, misuse the word terminal (and sometimes also console) to refer to terminal emulators rather than a straight-up text mode. This confusion of terms is usually not that big a deal, but to clarify, I’m expressly discussing how to get along with a system where X11 isn’t installed at all — and how to make yourself comfortable in such an environment.
Assuming you’re using a reasonably recent Linux distribution, your text mode
might already be using a framebuffer, and chances are, it might even be decent.
Getting things configured is system-dependent and beyond the scope of this
post, but there are plenty of resources on getting a reasonably performing
framebuffer regardless of your particular setup. Check for
/sys/class/graphics/fb0/name, though; if that file exists, then
congratulations: you have a framebuffer, and it even has a name!
If you’re using the standard VESA VGA driver, you might find that scrolling
output, like paging through a man page, is hideously slow. In that case, your
framebuffer sucks. Chances are good it’s just not optimized by default; try
video=vesa:mtrr=3,ywrap to your boot line and see if that changes
anything. Regardless, you might be better off looking into an accelerated
framebuffer driver that’s actually designed for your card.
You might want to investigate
fbset. Some drivers allow you to change the
resolution on the fly, among other settings. Others (like VESA) aren’t so snazzy.
You will (probably) also need to add your user to the “video” group for framebuffer-based applications to function, and probably also “input”.
Getting away from that VGA BIOS look just takes a quick
setfont, and can help
a lot in making your system not look like you just fished it out of the trunk
of an ‘85 DeLorean. Many Linux systems already use somewhat nice-looking
defaults; in particular, Ubuntu has a very nice console font.
Most of the fonts in the
kbd package are kind of same-ish, but there are a
few interesting ones (and by “interesting” I don’t necessarily mean “readable”):
Alexandre de Verteuil has assembled a nice gallery of the
There’s also a variant of Terminus in there, but if you enjoy that font,
chances are you’ll find the whole package far more appealing since it offers
many more sizes, variations, and character sets. At least on Arch, the X11 and
console fonts are bundled together, so installing it yanks in a ton of extra
dependencies, which is kind of annoying, but you can always extract the
files out by hand.
Depending on your distro, you might also be able to find some good fonts by searching your package manager for “console font” or similar. I grew up with Slackware, which had a heap of extra fonts that I got attached to; you might like some of them too.
You could also install my font tool gnacc and edit a font to your liking, or even try your hand at making your own. It’s a bit rough around the edges, but it works fairly well.
I’m just going to gloss over character sets, as Linux distros tend to default the console to Unicode mode nowadays and unless you have some reason to edit stuff in some other encoding, you probably won’t need to change that. However, if you handle a lot of different languages, you’re still quite likely to come across missing glyphs. It’s just a matter of fact; on the console, you have at most 512 characters to work with, and that just doesn’t cut the mustard in this day and age. Historically, with VGA hardware you even had to choose between more characters and more colors, because the 9th bit of the foreground color doubled as a “switch character set” bit. This meant that if you had a 512-character font, you could only really use 8 foreground colors! Thankfully, framebuffer modes eliminate this problem as they are fully capable of supporting bigger fonts without a loss of color precision. There aren’t a whole lot of 512-char fonts, though.
Side quest: fbterm
At this point, you might be thinking, “ew! This sucks!” Why yes it does. Since you’re restricted to “just” a couple hundred characters, you’re out of luck if you want even remotely decent Unicode support. There’s no TrueType fonts, no antialiasing, ugh gosh this is just terrible right?
You guessed it, there’s an answer: Fbterm.
Install that, get a couple nice monospace TTFs, spend a few moments reflecting
on the manual page and tap out an
Fbterm supports 256 colors, too, but you have to
export TERM=fbterm after
you start it, which is a bit wonky. You can hack around that with some
cleverness, and after you get it working, it’s great, and you get just
as solid glyph coverage as you would in X11 since it uses fontconfig.
It’s not for everyone, though. I spent quite a bit of time stuffing all sorts of odd glyphs into my custom console font, so I rarely need more glyphs than it provides, and none of my usual programs make use of the larger palette. I keep Fbterm for viewing Asian text, or if I come across some odd Unicode that isn’t rendering properly.
There are a few different ways to change the terminal colors. On the console,
the “best” way is by using
setvtrgb, because that way, even if you do a full
console reset, your color scheme sticks. (This also can be annoying if you’re
not expecting it, but it’s easy enough to undo with
setvtrgb vga.) It wants
its input in a really weird format, plus practically everyone makes their color
schemes for xterm and family, so you’ll probably want a converter.
Enter my palette tool, mostly because
I’m not aware of anything else that does quite what it does: it can read colors
from a variety of different file formats, and it works with
setvtrgb as well
as terminfo-style control codes to set the palette in the best way available.
Plus, it has a handful of color schemes available out of the box.
If you’d like to generate your own color scheme,
4bit might be a good starting point. Just
export as an .Xresources file, save it into
palette mytheme. Presto.
Spiff up the cursor
(Note that fbterm doesn’t support this at all, which is kind of a bummer.)
I’ve had a colorful cursor for some time, and have gotten quite used to it. It’s not quite as distracting as a blinking underline, and a bit easier to see — well, in my opinion; of course, this is entirely subjective.
Primary reading: VGA-softcursor.txt.
I just played with the numbers until I found something I liked. It seems to be a bit wonky in plain text mode, but it’s a solid, colorful block in a framebuffer.
If you just echo the softcursor control string, you’ll see the changes, but the
moment a program tries to set the cursor size, your nice software cursor will
disappear. To fix that, change the termcap settings to add your control string
$ infocmp linux > foo # edit foo and adjust the cnorm definition: # clear=\E[H\E[J, cnorm=\E[?25h\E[?113;0;220c, cr=^M, # ^^^^^^^^^ $ tic foo && rm foo # then log out and back in
My profile script also has a
tput cnorm to set the cursor up when I log in.
Set up the mouse
By default, you might not have any mouse support. If you’re used to xterm, you’re probably missing mouse paste, and even if not, some programs do use the mouse in text mode, so let’s get it running:
$ sudo gpm -m /dev/input/mice -t imps2
This ought to work well enough for typical cases. By default, though, gpm maps
right-click to paste, and if you’re really used to middle-click, you can
switch it with the
-3 option. I don’t bother, because my laptop only has two
(If you’re using systemd, of course, you can use that too.)
If your biggest complaint is that left and right alt are different, try
loadkeys linux-with-two-alt-keys.inc. I’d also suggest loading
which turns print screen into a compose key,
unicode.map to enter Unicode
character U+NNNN with Ctrl-Shift-NNNN. Have a look through
/usr/share/kbd/keymaps for others; there are many choices, including a wealth
of alternate keyboard layouts.
man loadkeys has a rundown of the file format,
showkey can clue you in on the keycode numbers.
My own keymap does plenty, including getting rid of caps lock, reassigning the Windows keys to something better, adding Unicode hex input, and adding some additional character sequences. Here’s the bit from my config to get alt-arrow keys working as expected:
string F103 = "\33\33[A" string F105 = "\33\33[D" string F106 = "\33\33[C" string F108 = "\33\33[B" alt keycode 103 = F103 alt keycode 105 = F105 alt keycode 106 = F106 alt keycode 108 = F108
I only bothered with the key sequences I tend to use, but with some work, it would probably be possible to add everything X11 supports.
Lastly: in case you don’t already have it, I highly recommend installing
tmux and making yourself at home with it. In fact,
I’d suggest that even when you’re in X11, or if you’re working over ssh, or
pretty much all the time. It’s a godsend. It permits you to do more than one
thing at a time, flip between tasks with tabs, and even split your screen into
windows like a (tiling) graphical WM would. It also has a ton of configuration
options, so I’d suggest spending a rainy afternoon fiddling with the settings.
Actually doing stuff
Okay, enough setup. Let’s actually get something done.
You can set the volume with
amixer if you like that better).
Simple enough, and you probably knew that.
For playing stuff, I typically use MPlayer. It’s straightforward, displays subtitles, reads DVDs, handles streaming, has a nice on-screen display, and plays damn near everything I’ve ever thrown at it.
Add this to your
# Output to the framebuffer vo = fbdev2 # Options particular to the fbdev2 video driver follow. # Don't put general options after here. [vo.fbdev2] # Without this, the constant status line updates will # trample all over the video, causing flicker. quiet = 1 # Make it fill the screen, scaling up or down as needed. # Adjust to your framebuffer's width; it'll scale the height. zoom = 1 xy = 1024
I’m not sure that the combination of
-xy is the best way to scale
videos, but I don’t know of a better way. (Dunno why it doesn’t just size them
automatically, though; it knows how big the framebuffer is!)
If MPlayer isn’t your cup of tea, VLC also works in the console, also plays a lot of file formats, and has a nice command-line interface, but it’s a bit fiddly as you kind of have to blindly type commands over top of the video as it’s playing, and it stretches videos to the full size of the screen by default, which isn’t so great if what you’re playing doesn’t match your display’s aspect ratio. I might have overlooked a setting or six, though.
If you want to browse YouTube, check out
youtube-viewer. It has a
surprising number of features, and it uses MPlayer for playback (with a
setting for using VLC instead).
I actually use MPlayer for audio, too. (Yes, it even plays tracker music, using libmodplug.) As with video, VLC is another good choice; try them both and stick with what you like.
For writing music, I’d be remiss not to point out that my own Schism Tracker works nearly as well in a framebuffer as it does in X11. :)
fbida gives you
an image and PDF viewer, respectively. It also has
exiftran, a neat tool for
manipulating JPEGs, and
ida, a basic image editor (which, alas, needs X11).
fbv, but I have had weird
issues with it, like not drawing parts of images. (Workaround:
which instead leaves junk on the screen.) On the other hand,
fbv happily runs
from within tmux, whereas
fbi complains if it’s not directly on a tty.
If you’d rather do things the hard way, you could also do something like this to view your images:
$ mplayer -really-quiet -idle mf://somefile.jpg
See, I told you MPlayer can do everything! You can even configure it to show images in a slideshow; how to do this is left as an exercise to the reader. ;)
I don’t do much image editing on the console, but for simple cropping and
convert gets me about 90% there. I’m not sure what
framebuffer-based drawing or editing apps there are, if any. For text art,
though, definitely check out Aewan. All I’m
going to say: layers. It has layers. It’s like Photoshop for text.
Taking a screenshot is simple enough:
cp /dev/fb0 screen.dump. If you want to
do it all proper-like, though, try
have a keybinding in tmux to fire off a script that snaps a screenshot and
tosses it in my “screenshots” folder with a description.
As far as I know, there’s no PowerPoint-ish application that runs on a framebuffer, but you could just as easily make “slides” out of a pile of images, and simply toss them at an image viewer.
Word processing software is looking somewhat dismal too. You might have luck with WordGrinder, but from what I understand, it’s in a very alpha state, so be ready for it to crash spontaneously. Alternately, you could just write Markdown; many editors provide reasonable syntax highlighting. (In fact, that’s exactly how I wrote this post!)
If your only interest is beating a Microsoft Word document into something kinda-sorta readable, there’s the blast-from-the-past converter, Antiword.
Spreadsheets are about the only thing that really has good console support,
and that’s with good ol’
sc, or the more feature-filled
sc-im. It has been
around since the dark ages and is worth another post in itself.
I still haven’t found a calendar application that really does everything I
calcurse, which might be more than enough for
you. It doesn’t seem to support syncing with remote sources or managing
multiple calendars, though, and I use the heck out of Google Calendar. If those
things aren’t that important to you, it might be just right. (I started
writing my own, but quickly got
frustrated with all the intricacies of the iCal format. Perhaps one day I’ll
pick it up again.)
You’ve probably heard of Lynx, but there’s more to offer. My personal favorite
text-mode browser is
w3m, which supports
drawing images on the console and has many nice features. (If it isn’t showing
you images, make sure
w3m -V contains
image, and also check to see if you
imlib2 installed. Some distros do weird things.)
A lot of people seem to prefer
If you’re a Gmail user, you might be pleased to find that the “basic HTML view” is actually surprisingly usable in w3m. As far as native clients go, though, the best choice is probably Mutt, but you’ll have to spend some time getting familiar with it.
If you’re an IRC user, you’ve surely already heard of Irssi.
I understand that there’s supposedly some decent console-based Twitter
clients, but save for the command-line examples in Python Twitter
Tools, none of them have felt right and
worked properly for me. I tend to use Twitter’s mobile web interface in
most of the time.
Whoever said Linux has no games? ;)
You probably know Nethack already. It’s been around for a long time and is quite popular. I’ve played it, but could never really get into it. Just not my style, I guess.
There’s a ton of little historical (as in 1970s!) gems in the BSD games
package; on Arch it’s named
bsd-games. Of note, there’s a few text
adventures, including the classic Colossal Cave
Adventure, Hunt the
Wumpus, and a
lesser-known game, Battlestar; some more action-oriented titles, like
(which is probably not the snake game you’re thinking of),
worm (this is
the one you were thinking of),
robots, and of course, Tetris; board games
like backgammon and cribbage; and a few other brain-engagers, like
quiz. These are all black-and-white, ASCII-based games, and are definitely
showing their age, but they’re still fun.
If you like arcade games, you might want to check out nInvaders, or the technically impressive Ambassador of Pain, written in a whole 64 lines of code (!). I also made my own Tetris clone which offers more niceties than the BSD version.
Enigma is a charming, deceptively challenging puzzle game. I’m not sure I have ever finished it, but it hasn’t stopped being fun. From what I understand, Chroma is a sort of continuation of this game, but I couldn’t get it to build.
For a game to “show off” to gamer weenies, check out
Ascii Portal. By default, it uses
PDcurses wrapped in an SDL layer, which does work in a framebuffer, but
that’s kind of convoluted and ridiculous. Fortunately it also happily builds
against ncurses (just
make nosdl, or
make nosdl32). The wealth of bundled
maps should last you quite a while.
Speaking of SDL, though, it’s quite popular in game development, which means in theory you should be able to run plenty of games in a framebuffer, as long as they aren’t doing weird and sneaky things with X11. I haven’t investigated this, though, so you’re on your own to explore the possibilities.
X11 is overrated. Text-mode programs are cool. Framebuffer-based programs are super cool. That is all.