Outdoor programming

If, like me, you live in Sweden or some other northern country, you will want to make the most of the summer season and spend as much time outdoors as possible. That means programming in the garden, with an old monitor that is not as bright as I would like. To somewhat overcome that, I choose fonts and foreground and background colours for maximum readability. As I do most of my developemnt using Emacs and the command line, I only bother with settings for xterm and emacs.

Settings for xterm

These setting are done in ~/.Xresource, and I take advantage of the fact that xrdb pre-processes its input using cpp. First I conditionally set two cpp macros:

# ifdef SUNNY
#     define WEIGHT bold
#     define FG     rgb:ff/ff/00
# else
#     define WEIGHT medium
#     define FG     rgb:a2/a2/00
# endif

Then I change all font and colour specifications accordingly. Before:

xterm*font:               -misc-fixed-medium-r-normal--15-140-75-75-c-90-iso10646-1
xterm*foreground:         rgb:a2/a2/00

After:

xterm*font:               -misc-fixed-WEIGHT-r-normal--15-140-75-75-c-90-iso10646-1
xterm*foreground:         FG

By default this gives a normal weight, light yellow text, but with SUNNY set, it gives a bold, industrial-strength yellow text. Command:

$ xrdb -DSUNNY=1 ~/.Xresources
$ xterm &
Settings for emacs

Here instead I use some Emacs Lisp. First the function fix-contrast:

(defun fix-contrast ()
  (interactive)
  (cond (window-system
         (set-face-attribute 'default nil :weight 'bold)
         (set-foreground-color "yellow")
         (set-background-color "black")
         (set-cursor-color     "yellow"  ))))

Then, near the end of the initialization file:

(when (> (length (getenv "SUNNY")) 0)
  (fix-contrast)
  (global-font-lock-mode 0))

It really is to obvious to mention that the SUNNY environment variable must be set before starting emacs:

$ export SUNNY=1
$ emacs &

You can reach me by email at “lars dash 7 dot sdu dot se” or by telephone +46 705 189090

View source for the content of this page.