Finishing Up the Emacs Video Player under Wayland?

This is the third part of a probably never-ending series of blog posts that started here and continued here. But! I think I’m getting pretty close to having everything working, so perhaps this is the final post?

So I’ve got this Lenovo Yoga thing, and the point of it is that you can flip it around to this “tent” position and then use it to watch movies. (And I’ve sown a handle for it so you can carry it around conveniently.) This means that you have to change the rotation of the screen when you flip it around. This normally happens automatically, but it’s so chaotic and unpredictable in Gnome (at least) that it’s unusable — instead of going 180° it may decide to go 270° if you’re not doing it exactly… right… and then you have to flip it back over and back again and AARGH.

So you have to disable the automatic flipperoo action and do the rotation “manually”. I.e., I’ve implemented listening to evdev and if I get a SWITCH_TOGGLE event, I rotate the screen. This is trivial under X, of course: You just use the standard xrandr function.

Gnome under Wayland, on the other hand, is a ball of spaghetti where everything is supposed to just happen magically, so there’s no built-in way of triggering something like this externally. Fortunately, it’s been implemented, and you’d think that Debian would pack up something as obviously useful, but nope. In any case, it’s easy enough to download and build yourself.

Since it’s a touch interface, it’s nice to be able to show a help grid…

… and the previous blog post was mostly about implementing an onscreen keyboard for this use case. And I used qiv to display the grid, since it’s got a convenient, simple interface, and allows having a transparent background. (But not alpha values.)

In addition to not having alpha support, it’s also just dog slow when doing transparencies. Look at how it’s painting the screen here — glitchy and ugly.

But! There’s something called pqiv which supports real alpha channels (meaning that I can have the rest of the screen “dim” a bit to make the overlay more readable).

See? All nice and stuff. However, there’s an issue with pqiv, too:

If I touch anywhere on the screen, it triggers some mouse handling logic designed to allow panning over an image. Fortunately, pqiv is written in an easy to hack way, so adding support for ignoring events is trivial.

I was also plagued by mpv killing Gnome when mpv exited, so I tried building the development versions of mpv and ffmpeg, and that seems to have fixed the problem? At least I haven’t seen any crashes today. (The mpv build system has changed once again, so I’ve updated the build instructions.)

Let’s see… is everything working now? Well, my setting to do nothing when I close the lid has disappeared from Gnome, and it’s now apparently a setting in systemd instead. *sigh* Because a user setting belongs in /etc/systemd/logind.conf instead of under /home, apparently?

And the Yoga has an OLED screen, so I really for it to switch the screen off when it’s not in use. And fast. (I’ve ruined another OLED screen by not taking precautions.) Gnome, of course, has mechanism for doing that — but it ties screen locking to screen blanking, and after googling for half an hour, I can’t find any way to disable that. Since I want the screen to blank fast when not in use, it’d be annoying to have to type in a password every time to unblank, right?

So I reached for the trusty xscreensaver, which indeed offers this. And it wakes up when I move the mouse, but… not when I hit a key!? What new hell is this!? And again, googling doesn’t help, but I find a lot of grumbling about the state of screensavers under Wayland, so perhaps the upshot is that this just doesn’t work because of… er… keyboard grabbing issues or something?

Fortunately, my Emacs is already listening to all events, so it’s trivial to just add some more code to wake up xscreensaver if somebody hits a key. This also means that this doesn’t work unless Emacs is running, but hey — let’s not be absurd! Emacs is always running!

(If you’re interested in looking at this work-in-progress code, you can find it on Microsoft Github. It’s probably not very usable for people in general, though — it’s geared towards my personal movie watching flow.)

But now everything is perfect, surely!

April Music

Music I’ve bought in April.

Shockingly few albums this month — I was away for a couple of weeks.

But my demos from my brother’s teenage punk band was released on CD, at least.

Oren Ambarchi / Johan Berthling / Andreas Werliin "II" (Official Music Video)

And the new Oren Ambarchi / Johan Berthling / Andreas Werliin album is swell.

Still House Plants - "M M M"

And the new Still House Plants album seems good, but I haven’t really had much of a chance to listen to it yet.

Onscreen Keyboards and Emacs and Stuff

This is part two of a series of blog posts that I’m sure is going to go on forever: Wherein I Bitch About Wayland And Modern Life In General.

So, last time, I finally bit the bullet and moved my travelling Yoga laptop to Wayland. This time around, I’m trying to get one more piece of the puzzle to work: The onscreen keyboard.

But first of all, I should perhaps explain my use case, because otherwise this will all seem incomprehensible. I mean, even more.

When I’m travelling, I bring a Lenovo Yoga laptop with me, because it’s so handy to watch movies on (in hotels and on planes etc). I guess most people solve this by bringing a tablet of some kind, but I’ve never found anything as convenient as just using one of these laptops. (Your mileage will vary.) Since the physical keyboard isn’t available in the “tent” position like up in the picture there, I’ve implemented a simple touch interface for Emacs (based on libevdev). Which means that I can just touch virtual squares on the screen to do various stuff:

Here’s the same view, but with labels on the squares to remind me where the various functions are.

Similarly, then actually playing the movie (with mpv), I have a whole bunch of convenient functions available by touching various squares…

… here with the grid shown with labels.

And all this works fine in Wayland, too, since it doesn’t really talk to Wayland stuff at all — it just pokes around in the Linux evdev hierarchy to get the events.

So what’s the problem? The problem is that sometimes I really, really need a keyboard, like when searching for things.

Now, all desktop environments have onscreen keyboards (or as some systems call them, “virtual keyboards” or the like). And… that’s the problem!

That is, there is no One True Onscreen Keyboard — instead they’re implemented for each specific desktop system, and the result is that they’re all lacking in features.

In the Good/Bad Olden Days, if people implemented a thing, they’d make sure that it worked for Linux, Macos, Windows, FreeBSD, whatever, and they’d slowly accrue a lot of features and become pretty useful. These days, a thing like this is implemented as a plugin — we’re here seeing the Onboard keyboard for Gnome Shell. But, as is always the case with these things:

Since it’s tied to Gnome Shell and uses internalish Gnome Shell features, it needs to be updated constantly as Gnome Shell changes. (And they usually aren’t.)

But if all these desktops have onscreen keyboards, why does it matter so much which one I’m using here? Because most keyboards don’t have the feature I need, which is to be able to pop up programmatically, and Onboard has:

qdbus org.onboard.Onboard /org/onboard/Onboard/Keyboard \
org.onboard.Onboard.Keyboard.Show

Beautiful, eh? All the other keyboards I’ve explored work “automatically” — that is, you enable the concept of “onscreen keyboards”, and they pop up when you focus on an input field or the like, like the amusingly named Improved OSK keyboard.

(The name is a typical result of these plugin application ecologies:

It’s a fork of something that already has a bad name, “Improved Onscreen Keyboard” — instead of making one app that works well, we get a large number of vague variations.)

So they’re all useless for my use case, which requires that I’m able to pop up a keyboard when I hit the right square on the screen.

And besides, it “pushes” all the windows up to occupy its own region, which is annoying.

Even if an ideal onscreen keyboard does exist, that fits my requirements like Onboard did — I have no faith in that it’ll still exist and be usable next month.

So what to do? Well, I guess I’ll just… implement yet another crappy onscreen keyboard, won’t I? Won’t I just.

My first thought was to use xdotool, but that doesn’t work under Wayland, of course. People are talking about ydotool as a replacement — but it’s not. It basically just lets you send rawish events to the currently focused window, which is … pretty weird. But I mean, you can switch windows by sending the correct key sequences, but that’s incredibly brittle, and I wonder what the use case for ydotool is at all. And:

Uhm… ok…

So my solution is very specific to my problem: Since I’m using Emacs to get the events, I’m also using Emacs to dispatch the events. That is, if the user hits the q square and we’re in “emacs” mode, we let Emacs handle the q event. If we’re in “mpv” mode, Emacs parses the ~/.config/mpv/input.conf file and sees which command the key maps to, and sends that over to mpv. For instance, for m we have:

(movie-send-mpv-command '((command . ["cycle" "mute"])))

Emacs is already communicating with mpv, of course, so this is pretty easy to add.

But I’m beginning to understand why all these onscreen keyboards are so tightly bound to specific desktop systems: Because the Wayland people haven’t been interested in providing any good protocols for automation and tinkering. (Extensions to the Wayland protocol have been proposed, and finally implemented by some compositors, or course, but not Gnome. But perhaps this will work in a general way in just another decade on Wayland.)

Anyway, let’s see what this looks like now, after tinkering with this for a couple hours…

So here’s the laptop normally…

And with my onscreen keyboard. Hey, that’s not so awful…

So what about when mpv is running? Yeah, that’s fine. I mean, it’s not as if I’m going to type a lot on this — it’s just as an escape hatch when there’s something that’s not available in the normal touch grid.

And I have to find a way to make mpv ignore the touches here, because it pops up some annoying stuff on the screen (title and some controls), but that should hopefully be simple enough.

Oops — Gnome Shell died? Again? That’s the third time that has happened when mpv is closing: Something mpv is doing makes Gnome Shell die. Oh, it’s a known issue, but nobody seems to know why Gnome crashes?

Tra, la, la. Being on Wayland is like being back on X in 1993 — random things you do can take down the entire laptop.

This is surely the Year of Linux on the Laptop!

Comics Daze

Wow, I’ve gotten a lot of comics lately, and I’ve been busy with other things, so I haven’t had time to read them. So it’s time for another Day Of Doing Nothing Except Reading Comics. And for music today — albums from 1996 only. Because.

Oval: 94diskont

12:27: Warnebi by Wiebke Boldvan (Fieldmouse Press)

This is excellent — it’s a pretty quiet book without much drama, and it feels very true and accurate.

And it’s never obvious where it’s going, so it’s pretty exciting. Nine thumbs up.

(The translation is sometimes a bit clumsy, though.)

12:43: Voyage d’hiver by Anne Brouillard (& esperluète éditions)

This is one of those er “accordion books”? Or whatever they are called.

I.e., it’s one long painting, really, but it’s kinda sorta slightly narrative, I think: We start with these people getting on a train…

… and then I think the rest might be what they’re viewing from the train? And it ends with them arriving at a new train station.

Lovely artwork and a fun concept. And the indicia says “quatrième edition”, so it’s a big hit.

12:53: Poor Helpless Comics! by Ed Subitzky (New York Review Comics)

This looks very cool… Design by Mark Newgarden.

It’s got interviews and stuff.

Oh, wow — these are very intricate (but amusing) works. Hm… OK, I think I’m gonna bounce — this looks like something I’d rather read some late night while drinking tea, so I’m shifting it over to the magazine holder next to my reading chair. But here on my comics couch, I’m instead continuing with:

Spring Heel Jack: 68 Million Shades

13:02: Girl Juice by Benji Nate (Drawn & Quarterly)

Oops, I’ve already read this.

13:06: Holy Fools & Funny Gods by Izar Lunaček (Uncivilized Books)

I buy everything that Uncivilized release by reflex, but this doesn’t really look like my kind of thing? I mean, it’s about religion?

So this is a comics version of a scientifictic (that’s a word) book Lunaček has published.

But the language here is often very awkward. “Those that see laughter as deriding the funny”? Uhm? Lunaček is Slovenian, but there is no translator listed, so perhaps he wrote this in English himself? There’s a guy credited with “language check” and a “translation editor”…

And… I’m sure this there are people that will find this interesting, but I read about a third and then ditched it. Sorry!

13:43: Galago #162 edited by Anders Annikas (Galago)

Sweden’s oldest running comics anthology has gone to a quarterly schedule (bad news) but has doubled its size (good news), so let’s have a look at the latest new-format issue.

As usual, there’s a theme for the anthology, and this time around it’s “music”.

So in addition to the comics, we also get a few articles, like this one about album covers done by comics artists.

But it’s mostly comics.

Heh heh.

It’s a solid anthology — varied in style, but somewhat unified by the theme.

Morcheeba: Who Can You Trust?

Hm, perhaps 1996 wasn’t the best year for music…

14:12: Mini Kuš (Kuš)

Five more minis I bought from here.

Tiina Lehikoinen does a very unsettling thing about a boy with a horse head.

Emelie Östergren’s book is very ambiguous.

Michael Jordan goes on a strange odyssey.

Anna Vaivare’s book is lovely and affecting.

Jyrki Heikkinen’s book is strangely unnerving (and looks great).

Five great little books!

DJ Krush: Only the Strong Survive

14:25: Return to Eden by Paco Roca (Fantagraphics)

This starts off with 20-ish black pages. Very portentous!

As usual with Roca, this book looks like it’s excavating more of his family’s history.

This is mostly about Antonia, which I’m guessing is either Roca’s aunt or mother? Probably mother, I’m thinking.

The bits about the family are interesting and sometimes gripping, but when Roca goes into Spain’s Fascist history, the book sort of collapses, I think? And this is something I’d be interested in, but the tone here is just… off.

And, yes, it must be about Roca’s mother, because we’re told that she has a son named Paco.

Anyway, it’s a good book, really — the ending is incredibly moving.

The Black Dog: Music for Adverts (and short films)

15:28: Smoke Signal edited by Gabe Fowler (Desert Island)

Most of the recent issues of Smoke Signal have been focused on illustration more than comics, I think? Not that there’s anything wrong with that, but it’s fun to get comics in this huge format.

Here’s Kade McClements on the dangers of small press comics publishing. Hm… is this a roman à clef kind of thing? A midwestern small press publisher (financed by selling both his kidneys) that pays in copies of comics only? I’m sure that’s not a reference to anything!

All the artists here get two pages each, which in most anthologies would have meant a pretty choppy reading experience. But since these pieces are (almost all, I think?) made with this format in mind, you get bigger stories than you’d have thought (Molly Dwyer here).

It’s just an insanely good anthology (Angela Fanche here). I’m not sure whether it’s available via mail order? Doesn’t look like it… So I guess you all have to make a pilgrimage to the Desert Island shop to pick up a copy.

16:07: Tank Tankuro by Gajo Sakamoto (Presspop)

This is fancee — it’s a very serious-looking hardback that comes in a sturdy slipcase. Hm… Oh, the slipcase is by Chris Ware. Duh!

These are comics from 1934 (I guess from the cover), and I guess I can see why the publisher went with a Ware cover instead of a cover by the featured artist. And if I want to be snide (and I always do), I could also say something about how wise it is to have the book in a tight slipcase, wrapped in plastic, so that nobody can see the insides.

Thanks for that footnote, translator! I’m sure nobody knew that.

I mean, it’s not that it’s bad… it’s pretty inventive? And for 1934, it must have been quite something.

But whenever things seem to be getting interesting (is he doing anti war agitation here?)…

… we just get One More Absurd Thing.

You know what this reminds me of? Very early Tintin — for instance Tintin au pays des Soviets from 1929: Hergé hadn’t figured out how to actually tell a story (and struggled with that for most of the next decade), so he’d just add one mad-cap humour/action scene after another until he had enough pages to call it a day. I’m assuming that Gajo Sakamoto likewise turned into a big deal later? (There’s a big essay at the end of the book, but who’s got time to read stuff like that? I’ve got comics to read!)

Paul Schütze: New Maps of Hell

16:37: A Simple Truth by Kavin Sacco (SLG Graphics)

SLG? Is that a new name for Slave Labor Graphics or something? Haven’t heard about them in decades.

The storytelling in this is really abrupt — it’s about a couple that miscarriages and then adopts a child.

But it’s hard to know how to read this book — the start of it is so filled with dread and random bad things that happen that I thought it was going to be one of those books where one gruesome thing after another was going to continue to happen, and I was waiting for the other shoe to fall when things start going better. And then it doesn’t — it’s instead… er… autobio? I mean, the dedication seems to point to it being autobio, but I don’t think it can be?

Anyway, it’s confusing on several levels.

16:56: Masters of the Nefarious by Pierre la Police (New York Review Comics)

Wow, this book is wonderful — it’s the funniest thing I’ve read in yonks. It’s like Tales Designed to Thrizzle by Michael Kupperman — it’s totally absurd.

Here’s the plot:

See? Best plot ever. And the wonderful thing about this book is that everything really kinda ties together — it’s not just one absurd thing after another, but a book that feels like a proper epic (even if it’s too short).

And he does while doing one laugh out loud silly thing after another.

A wonderful book.

Bundy K. Brown, Doug Scharin, James Warden: Directions In Music

17:18: The N* Word of God by Mark Doox (Fantagraphics)

Hey! This isn’t comics! *shakes fist in the general direction of Fantagraphics* And the artwork is, like, Photoshop collages with some additional drawing? It’s not really my thing — it’s kinda Juxtapoz-ish.

So what we’re getting here is a sort of alternate take on creation myths from the Bible and stuff, which, again, isn’t my thing at all.

But it’s pretty amusing in places.

It’s a slightly lazy book, though — when we get towards the middle of the book, there’s sometimes dozens of pages of text without any illustrations whatsoever.

Beth Orton: Trailer Park

*gasp* He’s right! I never thought of that! My god! I mean, Saint Sambo!

Sarcasm aside, it’s a more entertaining book that I thought it would be when I first opened it.

18:34: Uptight #5 by Jordan Crane (Fantagraphics)

The Mystery Mail sometimes has some really mysterious books — like this ten year old issue of Uptight.

The longest thing in the book is a chapter of Keeping II, which was collected and released to great acclaim a couple years ago.

But there’s a lot more stuff in here — a mysterious short story about a woman in a hotel room.

A mysterious longer sci fi story about some space miners.

And a shorter, but still mysterious, story about a guy floating at sea.

It’s a pretty amazing issue.

18:48: Undead by Pakito Bolino (Desert Island)

Actually, I’m not sure who the creator is here…

Another collagey book…

It’s fun, but I found it pretty disturbing by how much of this is sourced from low resolution JPEGs — there’s so much artefacting going on here that I found myself looking more at the artefacts than the collages.

Manic Street Preachers: Everything Must Go

18:59: The End

OK, that was a weird selection of books, and I think I should stop reading comics now because I’m getting annoyed, and I’m expecting whatever I’m going to read next to suck, which is the wrong attitude to have.

Might also have something to do with the music — I didn’t remember 1996 as being this uninspiring musically?