Sat, 23 May 2020 18:13:19 +0200
Better plumbing in Xorg with plan9port’s plumber
Well, this phlog was supposed to be about philosophy, but, well having not discussed what is philosophy, I am free to write about any topic I want. Radical freedom!
As we all know, the normal “plumbing” we experience in modern Xorg desktop environments is usually the xdg-open. It contains all the artful elements of the FreeDesktop code, including the lack of knowledge what it actually does and at least 20 ways of configuring, all of them inconsistent.
Well, replacing xdg-open with your own script is something I also tried, but well, the more rules you want the more chaotic it becomes. And then, I found out that plan9port plumber is perfect for the task.
It operates on something I mentioned - rules. It also has its own version of mimetypes, but they are secondary to rules, and are more of the part of plan9/port ecosystem, so if you do not use acme, you should not be stressed about it.
To, use it, we should first install plan9port, and setup the
environment variable PLAN9 to the location of plan9port, in Gentoo it
/usr/lib/plan9port and adding
$PLAN9/bin to our
we can start the plumber, by invoking the command
plumber, but it
will not work, as we do not have the configuration.
I would suggest starting with mine configuration (do not forget to copy
fileaddr file from the $PLAN9/plumb/ to your own
configuration is very clear and easy to use, as all the actions can be
done using regular expressions, therefore we have easy understanding of
which rule does.
To update the configuration, without restart the plumber, we invoke
9p write plumb/rules < $HOME/lib/plumbing command in order to write
the rules into the 9p port. If we want filesystem access to it, we
have to mount it using
9pfuse $(namespace) /tmp/mnt/plumb. This is
not necessary, but it might make writing scripts easier.
In order to replace the xdg-open “plumber” with plan9port plumber, you can simply link $PLAN9/bin/plumb, as xdg-open, in your PATH, so it is before the xdg-open. Then all the programs that want to invoke xdg-open will use plumb and you will now what the rules will do.