I finally got around to doing something I've been wanting to do for a long time: setting up a console typewriter, a laptop with CLI interface meant for typing.
The point is to have a laptop dedicated to writing that is light-weight so that I can take it with me anywhere. Making it CLI-only makes better use of the small screen on a portable device, makes me less likely to distract myself by clicking on stuff and gives me longer battery time (though how long is debatable.)
But isn't installing some minimal distro and firing up nano the easiest thing in the world? Yes, but you might want to do a little bit more. The following covers how to:
get basic stuff working
setup Dropbox on a CLI machine
get tmux going
get pretty fonts with fbterm
costumize emacs for wrting prose
I've gotten a lot of help with various issues from this forum . This how-to is a compilation of all that + the stuff I managed to figure out myself.
A small laptop with a decent keyboard is suitable for this purpose. I went with a pre-owned Lenovo IdeaPad s10-3 that I got really cheap. It has a 10,1' screen, is fairly light and gives me about 6½ hours of battery time.
A good choice of distro for this sort of thing would be Debian netinstall which offers you to install as little as possible. To get emacs24 I decided to go with testing. For some reason I couldn't get the testing image working so I ended installing stable and upgrading to testing which went pretty smooth. Note that the Debian installer gives you the option to load a proprietary driver for your wifi. Just find the appropriate deb for your chip, put in on a usb stick and plug it in when prompted.
When the installer asks you to "Select and install software" chose only Laptop Tools and System Utilities for a slim base system.
Even on a typewriter you'll need wifi for syncing your work with Dropbox (as will be covered later) or something similar.
If you didn't install a wifi driver during install, you should do it now.
Connecting to wifi with wpa_supplicant (already installed if you chose to install Laptop Tools) is pretty easy:
Check the name of the interface with:
Presuming you're using wlan0, edit /etc/network/interfaces and put in the following:
auto wlan0 iface wlan0 inet dhcp wpa-ssid YOUR-SSID-HERE wpa-psk YOUR-PASSWORD-HERE
$ sudo ifup wlan0
Your wifi should work now. There are some tools to manage wifi from CLI like ceni and wpa_cli but I actually thinks it's easier to edit the above file and:
$ sudo ifdown wlan0 && sudo ifup wlan0.
... to connect to another network.
I had high hopes for roaming with wpa_supplicant but still haven't got that working.
Acpid is a daemon to deal with acpi events: the events that register when you press the power button, close the lid of the laptop and the like. After installing the base system with Laptop Tools I was surprised to find acpid already running and configured with stock scripts in /etc/acpi/.
Before moving on to configure the acpi scripts, check what already works by pressing the power button, closing the lid and pressing special buttons like FN key combos to adjust brightness etc. If something important doesn't work, the Arch wiki is by far the best resource for info on configuring acpi scripts.
I like to keep things simple. Here are the acpi scripts that I use.
To suspend on lid close:
$ cat /etc/acpi/events/lidbtn event=button/lid LID close action=/usr/sbin/pm-suspend
To hibernate when power button is pressed:
$ cat /etc/acpi/events/powerbtn event=button[ /]power action=/usr/sbin/pm-hibernate
And to make the computer hibernate if power level is below 5% and the AC isn't plugged in:
$ cat /etc/acpi/events event=battery/* PNP0C0A:00 00000080 00000001 action=/etc/acpi/battery-low.sh %e
$ cat /etc/acpi/battery-low.sh # Critical battery level (acpi reports it at 5%) CRITICAL=5 battery_level=`acpi -b | grep -o [0-9]*% | sed s/%//` if [ ! $battery_level ] then exit fi if [ $battery_level -le $CRITICAL ] then if acpi -a | grep 'off-line' sudo /usr/sbin/pm-hibernate fi fi
Note that for the above scripts to work you need to edit sudoers to allow pm-suspend and pm-hibernate to be run without need for password as described here. The events may registers differently on your system. acpi_listen is a good way to check that.
Like on any other system it's nice to have a screenlocker. Vlock is a good screenlocker for the console. For some reason it's not in the testing repos but you can get it from sid.
Once installed add this script to /etc/pm/sleep.d/00screensaver-lock to lock the computer on each hibernate and suspend:
#!/bin/sh case "$1" in hibernate|suspend) /usr/bin/vlock -ans & ;; thaw|resume) ;; *) exit $NA ;; esac
This is a really good guide for getting Dropbox going on a CLI machine.
I recommend to connect the computer by way of the method under the heading "Type the link on a computer which has a browser".
For "Running on system startup" remember to also follow the Debian specific steps in the Debian/Ubuntu section.
If you don't want to sync all folders with you main machine but only want to sync a single folder you can do this already when Dropbox starts syncing:
$ cd ~/Dropbox & ~/.dropbox/dropbox.py exclude add *
That stops syncing of all existing folders.
$ mkdir typings
That new subfolder of Dropbox/ will be the only one that's synced.
Note: while not generally a problem I found that files and folders with the Danish characters æøå don't sync between my computers so beware of special characters.
So that's the basics. Now let's install tmux. It's not strictly necessary on a typewriter machine meant for single-tasking but, heck, tmux is pretty cool! Here's my really basic config. Note that inspired by this I've bound the prefix to C-\ (control + the backslash key just above it) to avoid conflicts with emacs keys and that works really good.
$ cat ~/.tmux.conf # prefix unbind C-b set -g prefix 'C-\' bind-key C-\ send-prefix # unbind the suspend key suspend unbind C-z # start with window 1 (instead of 0) set -g base-index 1 # screen mode #set -g default-terminal "screen" set -g default-terminal "screen-256color" # start with pane 1 set -g pane-base-index 1 # status line set -g status-utf8 on set -g status-justify left set -g status-bg default set -g status-fg colour12 set -g status-interval 2 # toogle status line - nice to hide it when your typing bind-key F2 set -g status off bind-key F1 set -g status on # clock and battery in right corner set -g status-right-length 60 set -g status-right '#[fg=brightyellow]bat:#(acpi -b | cut -d" " -f4 | cut -d"%" -f1)% #[fg=brightgreen] %H:%M' # use emacs keys set -g mode-keys emacs set -g utf8 on # resize panes - ctrl + arrow keys doesn't work in the console bind-key -r M-d resize-pane -D 5 bind-key -r M-u resize-pane -U 5 bind-key -r M-l resize-pane -L 5 bind-key -r M-r resize-pane -R 5
Fonts are important on a typewriter. You're going to be looking at them a lot. There's this menu to change the console font:
$ sudo dpkg-reconfigure console-setup
That offers you to choose between variations of three different fonts, neither of which are pretty.
That's why I was really excited when I discovered fbterm - a framebuffer teminal emulator that doesn't rely on X. It supports some fancy stuff like background image and other things but I will only focus on getting ttf fonts on the CLI machine.
Install fbterm and a font you like:
$ sudo apt-get install fbterm fonts-inconsolata
Edit these two lines in .fbtermrc to something like:
Fire up fbterm:
... and enjoy the font niceness. (You might see some weird errors about keys being unavailable to non-root users but don't mind that.)
Now that we have both tmux and fbterm installed we want them to launch at login and to play nice together. That took some work but after some trial and error I got it working with this in ~/.profile:
# if running bash if [ -n "$BASH_VERSION" ]; then # include .bashrc if it exists if [ -f "$HOME/.bashrc" ]; then . "$HOME/.bashrc" fi fi # include sbin in PATH if [ -d "/sbin" ] ; then PATH="/sbin:$PATH" fi if [ -d "/usr/sbin" ] ; then PATH="/usr/sbin:$PATH" fi # set PATH so it includes user's private bin if it exists if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH" fi setterm -blength 0 setterm -bfreq 0 if [[ ! $TERM =~ screen ]]; then SHELL=tmux fbterm fi
You should of course install your word editor of choice. If you don't have any strong preferences, I suggest that you try using emacs as a word processor. I have no religious adherence to emacs [a while later:] I love the hell out of emacs! Especially org-mode which is perfect for writing any kind of prose. I also like fountain-mode for writing in the fountain format, sort of the markdown format for screenplays.
In my configs I've made some hooks for text-mode. Note that both org-mode and fountain-mode are text modes so the hooks will apply to those as well. Another thing: key combos involving shift+control+alt don't work in the console. I don't know any fix for that but for the key combos in org-mode involving all three modifiers I've found a swell workaround: speed keys. Speed keys are single-letter keystrokes that are invoked when the cursor is at the beginning of a headline (if speed keys are activated.) For example U moves a headline one step up. You can see all speed keys by pressing ? at the beginning of a headline.
Here's my .emacs:
; get melpa going (require 'package) (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t) (package-initialize) ; open .fountain files in fountain-mode (add-to-list 'auto-mode-alist '("\\.fountain$" . fountain-mode)) ; don't wrap in the middle of words when writing prose (add-hook 'text-mode-hook 'turn-on-visual-line-mode nil) ; bye bye menu bar (menu-bar-mode -1) ; have writeroom style large margins when writing prose (defun my-set-margins () "Set margins in current buffer." (setq left-margin-width 20) (setq right-margin-width 20)) (add-hook 'text-mode-hook 'my-set-margins) ; cool org-mode navigation ; try it by pressing j in the beginning of a headline with speed keys on (setq org-goto-interface 'outline-path-completion org-goto-max-level 10) ; activate speed keys (setq org-use-speed-commands t) ; put a clock and a battery indicator in the mode line but don't show mail ; nice to have if you've hidden the tmux status line (setq display-time-24hr-format t) (display-battery-mode 1) (display-time-mode 1) (setq display-time-mail-string "")
That's it! Start typing ...
Last edited by tty-tourist (2014-04-16 20:06:21)
Cool tutorial. I've always wanted to get my typewriter back.
Fbterm is pretty handy as in my case it also sets the right resolution in ttys (-> fglrx). But I can't run it as a regular user without making it setuid (and I've already enough of those).
can't open frame buffer device! mmap /dev/zero: Operation not permitted Using VESA requires root privilege
sudo gpasswd -a alad video sudo setcap 'cap_sys_tty_config+ep' /usr/bin/fbterm'
but that didn't help. So what am I doing wrong?
Thanks for the feedback!
@ Alad: haven't seen that error. Startpage.com only gives me two relevant results when searching for the error: a Japanese site and a Russian Gentoo forum(!) There seems to be suggestions in the Russian forum about changing the resolution and reinstalling the vesa driver but well ... hard to tell if it worked.
Last edited by tty-tourist (2014-03-22 11:26:10)
Ok, I've read the manual :8
FRAME BUFFER DEVICE
Before executing FbTerm, make sure there is a frame buffer device in your system, and you have read/write access right with it.
fglrx doesnt have a frame buffer device, so it falls back to VESA mode which requires root.
Attention: 1) VESA support requires root privilege to work
This guide fixed it for me:
http://blog.samat.org/2010/11/09/High-r … and-Debian