:: [DNG] The real reason I like Linux
Top Page
Delete this message
Reply to this message
Author: Steve Litt
Date:  
To: dng
Subject: [DNG] The real reason I like Linux
Hi all,

A recent discussion here reminded me why I really like Linux. And then
a couple hours later I had a need...

I have four 8 foot shelving units: Three with seven shelves and one
with eight. Over the years, stuff's just been crammed into them, and
the situation is busting my productivity too much. So I made a diagram
of the four units, lettered A-D, each with shelves 1-7 (or 1-8 for one
of them). And because they're 4 feet wide, each shelf was divided into
l,c, and r (Left, Center, and Right).

As I cleared off shelves and put stuff in their new right places, I
realized those new right places would be forgotten. I needed a list of
shelf locations and the items stored therein. Because I'm the
originator of VimOutliner and feel very at home with tab indented
outlines, I am making the list in VimOutliner.

But there's a problem. There's no quick, practical way I'll be able to
search for the items at a location, or search for the location of an
item. No problem. Two AWK programs: One to write first by location and
to the right list the item, and another to write first by item and
later (thanks to AWK's printf() formatting) a nicely formatted
location. Pipe the output of either into the sort command, and I have a
nice, sorted list.

But geez, I don't want to look through a less session for an item or
location: I want a better interface. No problem, I piped the output of
sort into dmenu, which specializes in narrowing down lists using
keystrokes. Now three or four keystrokes and I can find my item. And
dmenu has a feature where the string you type doesn't even need to be
at the start of the string you're searching for. I could type "ball"
and get ball, baseball, baseball bat, etc.

But I don't want to run a command every time I need to search. No
problem: I'll have a special hotkey for this functionality that uses
either dmenu or my homegrown UMENU2 to bring up the list to narrow down.

Check this out:

==================================================
#!/usr/bin/gawk -We

function ltrim(s) { sub(/^[ \t\r\n]+/, "", s); return s }
function rtrim(s) { sub(/[ \t\r\n]+$/, "", s); return s }
function trim(s) { return rtrim(ltrim(s)); }

/^[^\t]/ {unit = trim($0)}
/^\t[^\t]/ {shelf = trim($0)}
/^\t\t[^\t]/ {side = trim($0)}
/^\t\t\t/ {printf("%-28s||| %s%s%s\n", trim($0),unit,shelf,side)}
==================================================

The preceding is executed by mini-shellscript find_loc.sh, as follows:


==================================================
#!/bin/sh
cat shelf_locs.otl | ./yield_loc.awk | sort | \
    dmenu -i -l 20 -fn "Ubuntu Mono:style=bold:size=16" \
               -nb yellow -nf blue -sb darkred -sf lightcyan
==================================================


It's called POSIX. With POSIX, I always have shellscripts, AWK and sort
ready to do my work for me. With POSIX, I can pipe a stdout into the
next stdin. With POSIX, I can plug in anything conforming to POSIX,
such as dmenu, a genius of a program that makes many hard user
interface situations simple.

I like Linux because it's POSIX. I could just as easily use OpenBSD,
but I want a works-every-time virtual machine, Docker is nice, Linux
runs a few more programs than OpenBSD, and with Linux I don't have to
deal with Theo and the boys. Hey, they're great guys and highly
skilled, but they're just not my type.

Now the guys from FreeDesktop would read this email and wring their
hands: Oh, no, your kludge involves programming, and most people can't
do that.

Oh really? 12 lines of code and they can't do it (or have a friend help
do it)? FreeDesktop.Org doesn't like me doing 90 minutes of programming
(and actually Lego(R) block assembly). Their preferred method goes
something like this:

* Use Gnome.
* Find Gnome software that solves your problem:
    - Ask your LUG
    - Ask on stackoverflow
    - Read every page on FreeDesktop.Org
    - Spend a day doing web searches
* Test the found softwares for suitability
    - If it fails a requirement, ask around for a fix
    - Experiment, experiment, experiment
* Install the necessary softwares
    - Adjust your workflow to comply with the softwares
    - Weave yourself through and around all the software
      requirements


Better yet, with the FreeDesktop.Org way, there's ongoing maintenance,
because every time some library author changes his library, your
FreeDesktop.Org style "solution" breaks and you need to beg for a
special package to fix your problem.

The FreeDesktop guys are geniuses. They can make specifications that
can turn the most attentive reader into a bowl of jelly. They can
implement sixteen levels of pointers and events and callbacks far
beyond the understanding of mortal man.

But I'll tell you the real geniuses. Thompson. Kernighan. Ritchie. Aho.
They knew you need to solve problems fast, so they made tools enabling
any fool to do just that. No need for event loops with callbacks and
message routing. And they made their tools so that you can have them in
a couple minutes or a couple hours, and then later make them pretty, if
you're a pretty kinda guy.

For me, it's all about POSIX.

SteveT

Steve Litt
March 2020 featured book: Troubleshooting: Why Bother?
http://www.troubleshooters.com/twb