Monday, December 28, 2020

the yak queue: end of year 2020

Yak shaving:

Noun: yak shaving (uncountable)

  1. Any apparently useless activity which, by allowing you to overcome intermediate difficulties, allows you to solve a larger problem.
    I was doing a bit of yak shaving this morning, and it looks like it might have paid off.
  2. A less useful activity done consciously or subconsciously to procrastinate about a larger but more useful task.
    I looked at a reference manual for my car just to answer one question, but I spent the whole afternoon with my nose buried in it, just yak shaving, and got no work done on the car itself.

As Lars is fond of saying, “queue your yaks, don’t stack them”.

That’s good advice which I’m bad at following, but early in 2019 I started a list of yaks where I can stash problems as they come up. Sometimes, at least, I manage to put something on that list and then go back to whatever I was nominally working on. I think I would recommend this practice as a way to eliminate some brain clutter.

It’s the tail end of the year now, cold and snowy outside, and I have some days off of work, so it seemed like a good time to go through the yak-shaving list and try some things. Here then is brief documentation of some problems solved (or further complicated) along the way.

linux audio: pacmd, pavucontrol, and pasystray

I have a Behringer UMC404HD audio interface for recording synthesizer output and other audio. You plug it into USB and it gives you some new interfaces. Works out of the box with Audacity and Ardour, no driver fiddling required. You can plug headphones into it and monitor what it’s recording, or use it as an output from the computer.

This all works pretty well, but at least on my Debian Buster system, it made juggling the builtin sound card, a set of external speakers, and the headphones plugged into the UMC404HD kind of clunky.

I searched and found out that you can use pacmd at the command line to switch which audio streams are going to which “sink”:

# Get a list of sinks - i.e. output devices, I guess:
pacmd list-sinks

# List sink inputs, i.e. apps sending audio somewhere:
pacmd list-sink-inputs

# Move an input to a different sink, for example from external
# sound card to builtin:
pacmd move-sink-input 79 0

Unfortunately, pacmd has verbose output and is tedious to work with. I was afraid I was going to wind up writing some kind of hacky wrapper script, but then people on Mastodon told me about pasystray and pavucontrol, which expose GUIs with a view of what’s playing and let you select what hardware it goes to. pasystray in particular gives you a little tray icon, which is pretty much what I wanted. There’s also pamix, which seems to expose some of the same info in a terminal interface.

These are in Debian, so:

sudo apt install pavucontrol pasystray

Not perfect, but much improved. I added pasystray to my xmonad startup script.

limiting wacom tablet pen input to a single screen under X.Org

I have a Wacom Intuos pen & touch drawing tablet. I don’t think this version has been made for a while, but it’s probably similar to current models. It acts as both a pen input device and a trackpad. I’ve always had the problem, when using two displays, where the pen input is mapped across both screens so that (typically) whatever image I’m working on I can only use half the tablet for.

I haven’t done much drawing on the computer since I got a second monitor anyway, so I never dug into it all that deeply. This time when I looked I found a blog post from 2017 on feldspaten.org with pretty clear instructions.

I wound up running (sample output in comments):

# I didn't have this installed:
sudo apt install xinput

xrandr | grep primary 
# DisplayPort-0 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 598mm x 336mm

xinput | grep -i Wacom
# ⎜   ↳ Wacom Intuos PT M Pad pad                   id=16   [slave  pointer  (2)]
# ⎜   ↳ Wacom Intuos PT M Pen stylus                id=17   [slave  pointer  (2)]
# ⎜   ↳ Wacom Intuos PT M Pen eraser                id=18   [slave  pointer  (2)]
# ⎜   ↳ Wacom Intuos PT M Finger touch              id=19   [slave  pointer  (2)]

xinput map-to-output 16 DisplayPort-0
xinput map-to-output 17 DisplayPort-0
xinput map-to-output 18 DisplayPort-0

I left the “Finger touch” input alone, and sure enough the pen input winds up locked to my primary display while the tablet can still be used as a trackpad across both displays.

Not totally perfect and I’m not sure what the appropriate way to make this permanent is, but at any rate it removes a frustration and makes MyPaint fun to use again.

google pagespeed metrics for p1k3.com

I don’t generally worry about Google’s opinion of this website, but it seemed vaguely useful to be aware of the things they’re tracking here. Profiling usually reveals something you’ve missed. So I read through the PageSpeed Insights for p1k3.com. A few things:

  • They suggest inlining CSS and JavaScript files. This would be easy enough, I guess, but I’m probably not going to do it. It’d bulk up each page with a bunch of boilerplate and anyway it kind of grosses me out.

  • Enable text compression: Ok, easy enough. I uncommented the line gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; in /etc/nginx/nginx.conf, which upped the score from 90 to 98, so I guess it just wasn’t enabled for… Some type. See also: nginx docs on compression.

  • They suggest minifying JavaScript. There’s a copy of jQuery on here - used for almost nothing, but handy every now and then. I swapped it out for the minified version of the latest version from the official download page. That got the score to 100.

  • It looks like I could tweak cache lifetimes on some files, but I think I won’t bother.

displaying moon phase emojis for current phase of moon

A while back I learned about the moon phase emojis:

🌑 🌒 🌓 🌔 🌕 🌖 🌗 🌘 🌑

I immediately wanted a way to display these in the terminal for (approximately) the current phase, but I didn’t initially have much luck finding a utility that would just spit out the phase of the moon without calling a web API or anything.

I realized while digging into this that gcal will display moon phases, although the documentation is impenetrable and trying to construct the right format string gave me a headache, so on to other approaches…

Paul Carleton wrote up a solution in Rust which uses a US Navy Observatory API, but I’d rather network access not be a requirement.

I did find a handful of libraries:

Of these, Samir Shah’s PHP code was the least hassle to work with. It doesn’t really satisfy my goal of “a shell script I can toss in ~/bin and use for whatever”, but it lets me stop thinking about the problem, so here’s a few lines of PHP called phasemoji (also on packagist, though that distribution isn’t set up in any kind of useful way).

Also, because I’m a dumbass, I bought a novelty domain and set up a web service. Behold: phase.city.

p1k3 / 2020 / 12 / 28
tags: topics/audio, topics/emoji, topics/google, topics/linux, topics/moon, topics/phase-city, topics/phasemoji, topics/php, topics/technical, topics/yak-shaving