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!