Mastodon

Emoji in GNOME on Arch Linux

Emoji 🚀 are ✨ great! ❤️ In a 🏠, with a 🐭, in a 📦, with a 🦊! The only places they really don’t belong are in the premise’s of movies, and CLIs (I’m looking at you, Kubernetes). One place I was sorely missing them though was on my Arch installation, until today that is.

For the uninitiated, under the hood, emoji are simply characters that were long-ago relegated to an unused corner of the Unicode table. As a result, this means two things for us; first, we’ll need to find a font that includes them, and that also means confronting… fontconfig *cue: wilhelm scream*. Second, we’ll need a way of typing them. In hindsight, that’s more like two and a half to three things, but I digress.

Finding the perfect font

Fonts are like opinions in that opinions are like assholes; everybody has one. The only things that everyone can agree on are that Arial is just a cheap knockoff of Helvetica and that Comic Sans isn’t the problem, people who use Comic Sans in inappropriate contexts are, but all of that goes without saying. There a quite a few emoji fonts out there, actually. As an iOS user, I should naturally believe that Apple’s emoji are hands-down the best (And I do, they’re absolutely gorgeous!) but sadly, due to licensing I couldn’t possibly install them (And no, I’m not using San Francisco Mono as my system monospace font! What could possibly lead you to ask such a ridiculous yet poignant question?). The few fonts that I did actually try include noto-fonts-emoji and twemoji-color-font. Had I thought about it for half of a second and realized that Noto emoji is used by Android, I would’ve stopped myself right there. No offense, but it looks like the typographer drew them grasping their pen in a fist like a cartoon character.

Noto color emoji font

"This is fine."

Next stop, Twitter Color Emoji, Twitter’s open-source emoji font. I’ll admit it, I think it looks pretty good. Having been burned once not five minutes ago, I decided to give the README a thorough go. Not even one quarter of a way into the document, I stumbled across this little gem:

Note: This requires Bitstream Vera is installed and will change your systems default serif, sans-serif and monospace fonts.DejaVu includes a wide range of symbols which override the Twitter Color Emoji characters… Bitstream Vera is the source of the glyphs used in DejaVu, 99%+ of people will not notice the difference.

You’d never guess, but I use DejaVu, and I quite like it, and I am one of the less-than-one percent who will notice the difference. So like any rational human being, I fire up yay and installed it anyway, foolishly confident in my skills and ready to pit them against fontconfig in glorious battle. After way more time than I should care to admit, I mostly had it worked out. Take that, RTFM! Happy as a clam, I carried on to the next step on my endeavour.

Selecting a Selector

As mentioned earlier, emoji are just characters, and so unless you’re Tom Scott, or don’t mind memorizing keycodes (I can’t find the forum post but yes, someone suggested that. I hope it was in jest 😰️), you’re going to want a way to select them graphically, preferably with some sort of search functionality included as well. Luckily for me, I use GNOME, which has an emoji picker built in that I knew nothing about and is apparently only documented in this Gitlab issue. Great! …except for the part where it only works, understandably, in Gtk applications. No worries, next stop, GNOME Shell Extensions! Everything useful in GNOME is à la carte these days it seems, and a system-wide emoji selector is no exception. Thankfully, there’s Emoji Selector, which includes a search feature! Hooray! Two clicks and we’re off to the races—oh no. Remember that quote from a paragraph ago that mentioned that DejaVu overrides Twitter Color Emoji but I thought I had fixed it? Turns out I hadn’t in this particular circumstance. And remember a paragraph ago where I had mentioned that I love Apple’s emoji but would NEVER violate their licensing? (If there any lawyers for Apple in the room, uh, you’re needed somewhere else) Ok, now that that’s taken care of, turns out that there’s an AUR package. I’m sure you’d never guess, again, dear reader, that in this twisting and turning tail there would be another turn, however this one is pretty minor. The conflicts list in the PKGBUILD is actually ridiculous. A quick 4dd and a few more incantations (sans any StackOverflow searches, thank you very much), my eyes were met with the prettiest emoji my system ever did see! Sadly, they were too beautiful for GNOME Shell it would seem, as in Emoji Selector they were rendered as silhouettes. UPDATE: Turns out I just needed to restart GNOME Shell. 🤷🏼‍♀️

GNOME Shell Emoji Selector extension

Again, "This is fine."

All was not forgiven, though. I still had a couple of qualms about using a shell extension as an emoji selector: First, it couldn’t actually insert the emoji; it only copied them to the clipboard. You still had to manually paste them into whatever text buffer you were editing in. Second, the selector itself is just a popup menu item; it will always appear in the upper right corner of the screen, regardless of where the cursor is. This is admittedly a very minor quibble on the surface but for crying out loud this is a post about me wanting to be able to effortlessly spam my writing with modern-day hieroglyphs! Anyway, the fixed position of the selector almost never anywhere near where I’m typing really interrupts the flow of whatever context I might be in. It’d be much more preferable if the selector were able to be implemented as a drop-down list like other tools, such as autocomplete, do. After (I’ll admit it) some StackOverflowing, I stumbled across ibus-typing-booster. I had some vague recollection of IBus complaining about things way back when I used Ubuntu, but I never really knew what it did. I wish I had bothered to learn earlier because “Wow!” is it powerful! IBus, or Intelligent Input Bus is a multi-lingual input-method framework. Basically, it allows a user to easily input characters regardless of their keyboard’s physical layout. As we know, emoji are characters (I’m sorry I keep hammering that, but I’m always really excited by realizations that beneath the many layers of abstraction that modern computing sits upon, almost everything is incredibly mundane in implementation), meaning that it’s perfect for the job and, as icing on top, IBus operates via a panel that’s rendered at the text cursor!

ibus-typing-booster

This is actually great!

Installation (at least on Arch) proved to be a little obtuse, as it requires executing a program called ibus-setup. *sigh* Maybe I’m just becoming curmudgeonly in my old age, but separate setup applications have always felt like an antipattern to me. Perhaps I’m naïve, but why not do whatever initial configuration is required during installation, or perform a check on every run? For a daemon especially, even having the user manually perform it would be preferable. Perhaps I’m only saying this because of what happened next, though. At the end of executing, a preference window opened with some configuration options and no obvious “save” or “cancel” buttons to be found. Upon closing the window and trying to setup ibus-typing-booster, I was greeted with an error dialog stating that the Ibus daemon wasn’t running. There wasn’t any mention of any DBus service or systemd unit to start. Did I miss something? Do I have to restart my session? I was consulting the Holy ArchWiki and the only nugget it offered was the suggestion that some environmental variables may need to be set, so I tried that, and restarted my session as part of it and sure enough, IBus was up and running, but not knowing what action specifically solved the problem is frustrating, and may even cause trouble in the future if I need to fix anything. To be fair, I wasn’t being very scientific about it. I could have tried restarting my session first, but to be honest, I was getting a little tired. Having accomplished the necessary prerequisites, I turned to the matter of configuring ibus-typing-booster. This may be another reason why, in retrospect, I may be unnecessarily critical of IBus's documentation because I tip my hat to the creator of ibus-typing-booster, Mike Fabian. His README and documentation are my new gold standard to strive for in terms of communicating how to use the tools I make to others. The instructions are detailed but not incomprehensibly dense, and include screenshots! Even though the version of GNOME I use had buttons in slightly different places, seeing that the windows presented matched what was shown content-wise is a welcome relief when you’re deep in a sequence of steps.

Conclusion

I hope you enjoyed this tale of trials and tribulations. I think it highlights nicely that, as often is the case in Linux and in life, the first solution is rarely the best, and that experimentation can lead us to discovering solutions to problems we didn’t even knew we had. In the example of IBus, I’ve been learning French and now will be exploring if it can help me with typing all of the accented vowels, c-cedillas, and guillemets more easily.

Post-scriptum

One side-effect of my desire to share what I learn with others is that it also really encourages me to go the extra mile to make sure what I come up with is well-polished. One such example is the instance of this mildly-irritating error initially given by ibus-typing booster:

☹ en_US dictionary not found. Please install hunspell dictionary!

This would appear as the top suggestion (sometimes multiple times) no matter what I typed, and if I’m being perfectly honest, had I not written this article, I probably would’ve suffered for a quite a while until repeated incidents of accidentally selecting it for insertion would drive me to find a solution. But knowing that there was a chance I wouldn’t be the only person benefiting from the extra effort (and honestly taking solace in the fact that the solution to this problem probably already exists on the internet), I fired up my search engine of choice and got to researching. Here’s what I found.

Hunspell is a spell checker based on MySpell that’s used in a surprising amount of software, according to their homepage. ibus-typing booster uses it for completion prediction, thus requires dictionaries for any languages it’s used with. Installing a dictionary requires jumping through a few more hoops than usual if it isn’t in your distro’s package repos (Luckily everything is in Arch’s repos). The process is detailed in this StackOverflow post but the tl;dr of it is to download the desired dictionary from Apache OpenOffice Extensions, extract the .otf file (It’s basically a .zip file. You can actualyl just change the extension and use something like unzip), and move the .aff and .dic files to a directory on the PATH given by hunspell -D.

Honestly it might be more convenient to just install Arch.

❋❋❋

First Do No Harm

Chef Sugar is a module for the infrastructure automation tool Chef. In September, it came to the attention of the module’s developer that Chef had entered a contract with the United State’s Immigration and Customs Enforcement agency. Citing "a moral and ethical obligation to prevent [his] source from being used for evil", he removed the code from its public repository. While this is not the first time a developer removing a public module has garnered attention, it raises a number of questions for the free software and open source communities, namely, “What should ‘free as in freedom’ actually entail,” and “what can developers actually demand of their users?”

Free Software isn’t Free

One of the Free Software Foundation’s mantras, mentioned earlier, is “free as in freedom,” and as anyone who’s taken an introductory philosophy course in University (*raises hand*) can’t help but mention (aside from the fact that they took Philospohy in University) is that freedom comes in two flavors, positive and negative. As a result of this dichotomy, the notion of absolute freedom is a fallacious one. One individual’s positive freedom to exercise an action can infringe upon another individual’s negative freedom from the consequences of that action being exercised.

On a less abstract level, free software imposes requirements on its users by way of waiving copyright restrictions in accordance with the terms enumerated in its license. The severity of these requirements vary from trivial attribution requests to the viral terms of Copyleft licenses. It is clear that the “freedom” of free software is bounded to some degree.

Ethical Source Software

Ethics in computing is hardly a glamorous topic, a sentiment that only compounds the a priori feelings of apathy towards it. What’s the worst thing that anyone has done with a computer? Invent Facebook? Unlike other professions, such as medicine, computing is seen as benign, and rightly so because it is only ever employed directly in benign tasks. The problem with this perspective however, is that it ignores the nature of computing; that computing is a means to an end, not an end in and of itself.

The most apt illustration of this idea comes from the earliest days of computing, before the advent of the semiconductor, when in 1933 the Deutsche Hollerith Maschinen Gesellschaft, a direct subsidiary of the newly-christened International Business Machines (IBM), began collating census data for the newly-appointed Chancellor of Germany, Adolf Hitler. Their work quadrupled the the number of citizens associated with Jewish heritage at the time, accounting for almost one-third the murders committed in concentration camps by the end of the war.[1]

Today, orders of magnitude more data is being processed with computational power unimaginable almost a century ago, with the aim of identifying persons in the United States without the necessary heritage or legal documents. Though the intent may be dissimilar from that of the leader of the Weimar Republic, the results are not. This is the power of computing: it confers upon the user a multiplicative force that warrants even greater care.

David and Goliath

Now, dear reader, I’m sure you’re thinking, “That’s all fine and good, but I’m just one developer. You honestly expect me to be able to go toe-to-toe against *insert big corporation here*!?” Yes, I do, because others have, and made a mark. Case in point: The much-maligned JSON license, a near-carbon copy of the much-beloved MIT license, with one additional caveat:

The Software shall be used for Good, not Evil.

These nine words ring of origins on Mount Sinai and have caused concern among fellow developers and lawyers alike, with users (in a twist directed by M. Night Shamalan) such as IBM, asking for special licensing. Listening to the JSON licenses’ creator, Douglas Crockford, speak about it gives one the sense that its inception wasn’t exactly driven by serious ethical concerns regarding the use of JSON, however it does demonstrate that licensing does matter and can be a powerful tool if wielded properly.

A Hippocratic Corpus for the Rest of Us*

One of the biggest criticisms of the JSON license, that I must agree with, is that the wording is ambiguous at best. Assuming that you and I would like to contribute to a cause greater than mere trolling, we will need a license with a little more substantive language. Enter, the Hippocratic License, created by Coraline Ada Ehmk, of Contributer Covenant fame (yes, the one that broke the Linux Kernel Group). Written in the spirit of the oath sworn by doctors for millennia with 0% of the problematic wording of the original (seriously, go read it, it’s great!), the Hippocratic license embodies the (one hopes) same spirit of the JSON license while deriving its language from international law.

It is truly incredible that individuals are taking a stand for what they believe in ways that go beyond slack-tivism. While changing the terms by which others can use some code you wrote and put on the Internet probably won’t prevent future genocide, we’ve shown that it can help hinder efforts by those who wish to amplify their effectiveness with such tools, albeit indirectly, and if nothing else, sends a message that such actions are not tolerated.

If you have code you wrote and put up on the Internet like I do, please consider updating your licenses, and whether or not you distribute code publicly, consider contributing to further the important work of putting the power of computing to the use of making the world a better place for all of us (and come on, you’re already giving $5 per month to that podcast about Apple computers and magic tricks).

* Nailed it.

References

  1. Black, Edwin (2009). IBM and the Holocaust: The Strategic Alliance Between Nazi Germany and America’s Most Powerful Corporation (Paperback) (Second ed.). Washington, DC: Dialog Press. OCLC 958727212.
❋❋❋

An rsync Crash Course

Whether you’re a beginner Bash scripter or seasoned sysadmin, rsync is an indispensable tool for efficient file transfer and synchronization. It’s easy to use, yet incredibly powerful, and beguiles many a script kiddie and cargo-cult programmer alike, myself included at times. While I do encourage everyone to #ReadTheDocs and open man rsync, it’s less of a page and more of a novella, so let’s take a bird’s-eye view and look at some of the more useful options, and practical examples of their application.

Usage overview

$
rsync [option(s)] [source(s)] [destination]

Like most commands, rsync has a fairly straight-forward signature: Options follow the executable name, then a list of sources to send, with their destination at the end.

Options

  • -a, —archive, same as -rlptgoD, recursively sync source directory while preserving all attributes except hard links

  • -D , same as —devices —specials, syncs system files used to represent connected devices and special files such as shortcuts, and sockets and pipes related to inter-process communication.[1]

  • —delete, delete all files in the destination not present in the source

  • -e, —rsh=COMMAND, specify the remote shell to use

  • -g, —group, preserve group

  • -h, —human-readable, —progress

  • -l, —links, copy symlinks

  • —safe-links, ignore symlinks that point outside the directory from being copied

  • -n, --dry-run

  • -o, —owner, preserve owner

  • -p, —perms, preserve permissions

  • -r, —recursive, recurse into directories in source

  • -t, —times, preserve times

  • -u, —update, skip files with a newer timestamp at the destination

  • -v, —verbose, increase output verbosity

  • -z, —compress, compress file data during the transfer

  • —include=PATTERN, only sync files matching the given pattern

  • —exclude=PATTERN, skip files matching the given pattern

  • —include-from=FILE, read inclusion pattern from given file

  • —exclude-from=FILE, read exclusion pattern from given file

  • —files-from=FILE, read list of source-file names from given file

Sync local directories

$
rsync -avz —delete /src/directory/ /dest/directory

Note that the trailing / on a source directory indicates to copy its contents rather than the directory itself.

Sync remote directories

$
rsync -avz -e ssh /src/directory/ user@host:/dest/directory

macOS

When sending the contents of a volume from its root on macOS, save yourself some cycles and remember to exclude a few volume-specific hidden directories.[2]

$
... —-exclude={ '.fseventsd', '.Spotlight-V100', '.Trashes' }

Permissions and owners and timestamps, oh my!

For most use cases, the --archive flag works perfectly well, but not all. One such case is sending files to a directory with a different owner, for example /var/www on a web server. One probably wouldn’t want to preserve ownership or group of the files being sent in that case, and would want to simply use just -r instead of -a.

Conclusion

rsync is a powerful yet easy to use file transfer and synchronization utility that has a spot in every developer’s tool belt. While it is just as easy to misuse at times, having an understanding of its most common use cases will help guide you through the documentation and navigate those edge cases where --archive isn’t quite the answer.

Additional Resources

References

  1. What is the -D switch in rsync? - Ask Ubuntu

  2. Rsync cheatsheet