programming musings
31 Aug 2020



Ted Chiang is up there with Greg Egan as my favourite hard SF living author, and his Exhalation was just as good as his previous books. While the first story about time travel didn't look exceptional (even though it's easily one of the best in that micro subgenre i've read), it's immediately followed by a charming entropy metaphor, an insightful mini-essay on free will, and on and on he goes, in a deluge of originality and, often, insight.

In Science Fiction Doesn’t Have to Be Dystopian, Joyce Carol Oates writes a much better review, but just reading the book is your best option!

Tags: books
27 Aug 2020

in no particular order xii

Interesting bits elsewhere:

Tags: sundry
08 Aug 2020

xmobar: a battery trick

i've been maintaining xmobar for more than a decade now, and i still use it daily and tweak it almost as often. With almost a hundred contributors besides myself, and many bugs to solve, i am always learning new things. The latest one, that font awesome thing everyone seems so fond of.

i just decided to add a bit more icons to my configuration, and, in particular, to have a battery monitor that displays graphically an approximation of time left.

For that, you specify the new font as one of the additional fonts:

additionalFonts = ["xft:FontAwesome-9"]

Then, find a list of glyphs that represent a charging battery (the ones between 0xf240 and 0xf244 work well), and assign that to the -f flag (the foreground of horizontal bars) with -W (the display width) set to 0, and use it in your battery monitor template, which should include somewhere <leftbar>; for instance:

BatteryN ["BAT0"]
         ["-t", "<acstatus>"
         , "-S", "Off", "-d", "0", "-m", "3"
         , "-L", "10", "-H", "90", "-p", "3"
         , "-W", "0"
         , "-f", "\xf244\xf243\xf243\xf243\xf242\xf242\xf242\xf241\xf241\xf240"
         , "--"
         , "-P"
         , "-a", "notify-send -u critical 'Battery running out!!!!!!'"
         , "-A", "5"
         , "-i", "<fn=1>\xf1e6</fn>"
         , "-O", "<fn=1><leftbar>  \xf1e6</fn> <timeleft>"
         , "-o", "<fn=1><leftbar></fn1> <timeleft>"
         , "-H", "10", "-L", "7"
         ] 50 "batt0"

where 0xf1e6 displays a little plug. here's a peek at the corner of my desktop with a charging battery:


The only thing we needed to enable this little feature was to implement indexing on the foreground bar string when the special value 0 is passed, a really small change codewise. Moroever, the feature is generic and applies to any horizontal bar in any monitor, so one can play similar tricks in many places.

This feature will be available in the forthcoming xmobar 0.36 release, but you can of course just grab it from its master branch.

Tags: programming xmobar
06 Aug 2020

in no particular order xi

Interesting bits elsewhere:

Tags: sundry
23 Jul 2020

in no particular order x

Interesting bits elsewhere:

Tags: sundry
14 Jul 2020

in no particular order ix

Interesting bits elsewhere:

Tags: sundry
09 Jul 2020

this is shakespeare


This Is Shakespeare: How to Read the World’s Greatest Playwright by Emma Smith

Emma Smith's tour through some of Shakespeare plays was a really interesting read. Her main thesis is that Shakespeare rarely provides answers, he just asks questions and plagues his plays with ambiguity: that's why every age finds works so modern, the key to their eternal relevance. We pick the interpretation that suits our times best, the genious being, of course, in writing something so malleable and covering so many facets of human experience.

One of the ways of being this wide is by a paucity of stage directions. For instance, in the final monologue of The taming of the shrew, there's no indication about the attitude and body language of Kate while she delivers her surrender, so one can imagine her kneeling and make it the misoginistic piece, or standing with a sneer, a stalwart of feminism (when i am feeling cynic, i suspect that Shakespeare was just being lazy, and the meaning was so obvious to everyone at the time, that no directions were needed).

Another funny example is discovering how A midsummer's night dream, our children and Christmas favourite, can very easily be read in a rather more lewd way.

I was also a bit surprised by how often Shakespeare reused and adapted plays and histories by other authors, most of them now forgotten. His genious here was of course writting them better and twisting their plots almost invariably to improve them; but it's funny to imagine what would have become of him in modern times, where the social media crowd would have immediatedly cried wolf, pointing their fingers to the plagiarist (and god knows what else) and asking to #CancelShakespeare.

Anyway, a very entertaining and highly recommended book!

Tags: books
07 Jul 2020

in no particular order (viii)

Interesting bits elsewhere:

Tags: sundry
02 Jul 2020

the mode lines i have not seen

i don't dislike emacs' mode line, i just wish (possibly out of a fetish for simplicity and minimalistic user interfaces) sometimes it wasn't there.

There are lots of packages out there "modding" the content and looks of the mode line, but in general it's not looks that bother me and i've seen a tendency among them of not being good at covering all the bases: when using any of these packages, i've always found myself having to write extra code to bring back some bit of information or another.

What i really wanted was the ability to hide the mode line for inactive buffers (and, every now and then, the active one too), and, ideally, to do that on a per frame basis (as frames double as my workspaces, and they're thematic, i want, for instance, mode lines in all my w3m inactive buffers, and usually no mode line for my active PDF document).

Sometimes, one's wishes just come effortlessly true:

(defun jao-toggle--face-height (face &optional all-frames)
  (let* ((h (face-attribute face :height (window-frame)))
         (nh (if (eq 'unspecified h) 1 'unspecified)))
    (set-face-attribute face (when (not all-frames) (window-frame)) :height nh)))

(defun jao-toggle-mode-line (&optional all-frames)
  (jao-toggle--face-height 'mode-line all-frames))

(defun jao-toggle-inactive-mode-line (&optional all-frames)
  (jao-toggle--face-height 'mode-line-inactive all-frames))

(defun jao-echo-mode-line ()
  (message "%s" (format-mode-line mode-line-format)))

That's it: all the requirements above fullfilled in a dozen lines of elisp. As you see, the trick is very simple: one can set the height of the mode line's face to 1, making it display as a line, and faces are frame-local entities.

In my init file, i then call (jao-toggle-inactive-mode-line t), turn it back on some functions initialising my dedicated frames. jao-echo-mode-line comes in handy when i just want to see my active mode line's contents momentarily. i even found a good place in the thinkpad keyboard for shortcuts, with keys i literally never use for anything:

(global-set-key (kbd "<home>") #'jao-toggle-inactive-mode-line)
(global-set-key (kbd "<end>") #'jao-toggle-mode-line)
(global-set-key (kbd "<insert>") #'jao-echo-mode-line)
Tags: emacs
03 Jun 2020

in no particular order (vii)

Interesting bits elsewhere:

Tags: sundry
Other posts
Creative Commons License by jao is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.