Fun with DPMS; or, An Emacs-Based Screensaver

I’ve got a bunch of monitors, large and small, that (in general) are always on. Because I’m too lazy to switch stuff off and or.

They display some useful information, but are largely decorative (i.e, some of them display temperature data, and some use xscreensaver to show what albums are playing).

But I’ve got the rest of the lights and stuff in the apt to switch off when I push the “I’m going to bed” button on the wall. I thought it might be nice to have all the monitors also switch off at the same time? And then I could link the “I’m awake now” button on the wall to switching all the monitors on again.

So cyber.

I thought this was going to be really easy, but… you know… computers.

First of all: Switching a screen off is easy:

$ xset dpms force off

And then it’s off.

$ xset dpms force on; xset -dpms

to switch it on again and disable power management again (to avoid the monitors switching themselves off again on their own volition).

So far so good!

However, there’s like a dozen things that feel free to wake monitors up.

mpv

Easiest first: I’ve got a little monitor that plays Youtube 24/7 (and displays weather data).

It would switch itself on immediately, because it uses mpv to display the youtube vids. To switch that off, just say –no-stop-screensaver.

Stereo Computer

The screen on the computer I use to control the stereo would switch it self on whenever the song changed, and after a bit of trial and error and more code reading, I found this:

(set-mouse-pixel-position (selected-frame) 2000 0)

It’s code designed to just move the mouse pointer off the screen. And it turns out that that makes X wake the monitor up!

I guess that… makes sense? I mean, moving the mouse is supposed to wake the screen up, so…

I added the following guard:

(defun jukebox-monitor-on-p ()
  (with-temp-buffer
    (call-process "xset" nil t nil "q")
    (goto-char (point-min))
    (search-forward "Monitor is On" nil t)))

xscreensaver

Many of the larger screens use xscreensaver to display the sleeve of whatever album is playing, and xscreensaver wakes the monitor up after just a few seconds. Isn’t that ironic!

Don’t you think?

It’s like a screensaver that switches on a screen that’s already saved, it’s like

Oh, where was I…

xscreensaver has a bunch of DPMS-related options:

dpmsEnabled:	False
dpmsQuickOff:	False
dpmsStandby:	24:00:00
dpmsSuspend:	24:00:00
dpmsOff:	24:00:00

But none of them seem to help with this problem. xscreensaver stubbornly wakes shit up. What’s up with that, jwz?

So.

The only solution for this problem is to write an Emacs-based screensaver.

Obviously.

It uses the xelb library to query the idleness (to schedule when to start saving the screen) and to query/restore focus after closing the screensaver window.

Man. It’d be great if somebody could write a manual for xelb. Working with it is kinda frustrating because you just have to poke around, looking at examples, until you suddenly get something that works. I spent, like, seven thousand hours (approx.) trying to get the idleness out of it until I guessed (by looking at what exwm did with randr extensions) that you had to say

(xcb:get-extension-data x 'xcb:screensaver)

before trying to call the xcb:screensaver:QueryInfo function.

[Edit: Emacs give me almost all events that’s given to the frame (mouse and keystrokes), but not when the user presses shift, etc. Is there a way to get something like xcb_wait_for_event out of the xelb library?]

SO THERE YOU ARE

Isn’t it weird how these trivial projects tend to spiral out of control?

Especially for certain people?

Don’t you think?

(Not) HDR10 to sRGB

I’m going to be watching a bunch of 4K movies in High Dynamic Range (i.e., UHD HDR) later this year, and I’m going to be screenshotting a bit. Now, as you can see from that blog post, I’m using an HDMI splitter that sends the UHD HDR bits to the TV, and sends 2K SDR bits to the screenshotting box.

There’s a right way to do the SDR conversion and a wrong way, and the HDMI splitter does it the wrong way.

As that web page explains, if you just do the moral equivalent of

ffmpeg.exe -i input.mkv -vf select=gte(n\,360) -vframes 1 output.png

then you’re going to get washed-out images. HDR10 is a 10-bit BT.2020 colourspace, and we want to end up in the 8-bit BT.709 colour space.

And as that page tells us, you can do that in a pretty sensible way, or… you can just discard some bits and end up with a washed-out low-contrast image.

Here’s an example of what comes out of the SDR port:

You can do something simple like:

convert -contrast-stretch 0.20x0.10% IMG_53.JPG norm.jpg

and get something that looks acceptable:

But that’s obviously not the “correct” transform.

As Wikipedia explains, the HDR10 format uses a static non-linear transform in the Rec. 2020 colour space. The formula is here: It’s a “perceptual quantizer” (PQ). “PQ is a non-linear electro-optical transfer function (EOTF).” So there.

So! Here’s my question, that I also asked here:

Given that we have discarded some bits, there’s no way to get the ideal SDR version of these images. But: What has been discarded is predictable (I’m guessing the upper? lower? bits?), and all the HDR10 math stuff is static.

A helpful person on the ImageMagick forum suggests using a sigmoidal contrast stretch with lots of “auto” in the parameters, and that does give me pretty good results in all the test images, so it’s “good enough”.

But since all the things that have been done to the signal is static, there should be a way to write a static transform from these non-HDR10 images to SDR.

So, like, first convert back to 10-bit space (with zeroes for the missing bits?)

And then just do the inverse of the PQ EOTF, and then chop bits again into SDR, as this explains, using one of the nice algos there.

Surely this must be a fun math challenge for somebody (who isn’t me!).

Included below are a few more screenshots of movies and TV series that are HDR10 according to the TV.

4AD 1994

Listen to 4AD 1994 on Spotify.

The most important thing that happened in 1994 was that Kristin Hersh launched her solo career. While not really that radically different from her Throwing Muses music, it gave us more Kristin Hersh, and that’s always better, right?

Also: 4AD signed Lisa Germano and released her stunning Geek the Girl album. It’s all an album on 4AD should be: Scary, beautiful, gripping.

Lush released their most accomplished album, Split, and some spiffy EPs, too.

Let’s see… Oh, yeah, Frank Black was such a dick that Ivo Watts-Russell let him go, and the incident was perhaps also instrumental in him withdrawing even further from being involved with artists on 4AD, according to that 4AD biography you’ve all read, no doubt. If you haven’t, you should.

Art-wise, I think that Vaughan Oliver and Chris Bigg of v23 make something of a comeback this year. After a couple of years of uneasily adjusting to CD-first designs, and failing a lot, this year we get a number of kinda stunning covers, including the Shinro Ohtake things for Kristin Hersh’ releases.

Some significant releases are missing from Spotify this year (in addition to the usual promo releases): Perhaps most importantly, Inconsiderate Bitch by Lisa Germano. 4AD label boss Ivo remixed a bunch of Germano songs and put out a five track EP, and it’s rather brilliant, I think. But you probably have to get it on discogs.com if you want to listen to it.

But the 10″ limited Head to Toe by The Breeders, BADD4012, is also missing, which is just weird, because… it’s the fucking Breeders, right?

The second version of Frank Black’s Headache EP (BADD4007CD) isn’t on Spotify either; something we can all be thankful for.

1994

 BAD4001
Kristin Hersh — Your Ghost

Your Ghost, The Key, Uncle June and Aunt Kiyoti, When the Levee Breaks

 CAD4002
Kristin Hersh — Hips and Makers

Your Ghost, Beestung, Teeth, Sundrops, Sparky, Houdini Blues, A Loon, Velvet Days, Close Your Eyes, Me and My Charms, Tuesday Night, The Letter, Lurch, Cuckoo, Hips and Makers

 TAD4003
Lisa Germano — Inconsiderate Bitch

Happiness (remix)*, Energy (remix)*, Puppet (remix)*, Sycophant (remix)*, (Late Night) Dresses (remix)*

 BAD4004
Red House Painters — Shock Me

Shock Me, Sundays and Holidays, Three-Legged Cat, Shock Me (rerecorded), Untitled

 lp45496
The Glee Club — Mine

Need, The Blame, No Reason, Bad Child’s Dolly, Already There, Free to Believe, Drives You Away, Remember the Years, All The Promises, Take you There, Icy Blue

 CAD4005
Lisa Germano — Happiness

Bad Attitude, Destroy the Flower, Puppet, Everyone’s Victim, Energy, Cowboy, Happiness, The Earth, Around the World, Sycophant, Miamo-Tutti, The Dresses Song, The Darkest Night of All

 TU7CD
Insides — Clear Skin

Clear Skin

 AD4006
Kristin Hersh — Strings

A Loon (strings), Sundrops (strings), Me and My Charms (strings), Velvet Days (strings)

 BAD4007
Frank Black — Headache

Headache (David Bianco), Men in Black, At the End of the World, Oddball

 BADD CD4007
Frank Black — Headache

Headache*, Hate Me*, This is Where I Belong*, Amnesia*

 BAD D4008
Lush — Hypocrite

Hypocrite, Cat’s Chorus, Love at First Sight, Undertow (Spooky Remix)

 DAD4009
Frank Black — Teenager of the Year

Whatever Happened To Pong?, Thalassocracy, (I Want To Live On An) Abstract Plain, Calistan, The Vanishing Spies, Speedy Marie, Headache, Sir Rockaby, Freedom Rock, Two Reelers, Fiddle Riddle, Ole Mulholland, Fazer Eyes, I Could Stay Here Forever, The Hostess With The Mostest, Superabound, Big Red, Space Is Gonna Do Me Good, White Noisemaker, Pure Denizen Of The Citizen’s Band, Bad, Wicked World, Pie In The Sky

 BAD D4010
Lush — Desire Lines

Desire Lines, White Wood, Girl’s World, Lovelife (Suga Bullit remix)

 CAD4011
Lush — Split

Light From A Dead Star, Kiss Chase, Blackout, Hypocrite, Lovelife, Desire Lines, The Invisible Man, Undertow, Never-Never, Lit Up, Starlust (rerecorded), When I Die

 BADD4012
The Breeders — Head to Toe

Head to Toe*, Shocker in Gloomtown*, Freed Pig (originally appeared on «Sebadoh III»)*, Saints (htt)*

 BAD4013
Pale Saints — Fine Friend

Fine Friend, Special Present, Marimba, Reprise

 CAD4014
Pale Saints — Slow Buildings

King Fade, Angel (will you be my), One Blue Hill, Henry, Under Your Nose, Little Gesture, Song of Solomon, Fine Friend, Gesture of a Fear, Always I, Suggestion

 DAD4015
Dead Can Dance — Toward the Within

Yulunga (spririt dance) (live), Rakim (live), Song of the Sibyl (live), I Can See Now (live), American Dreaming (live), Cantara (live), The Wind That Shakes The Barley (live), I Am Stretched On Your Grave (live), Desert Song (live), Oman (live), Tristan (live), Sanvean (live), Don’t Fade Away (live), Persian Love Song (live), Piece for Solo Flute (live)

 CAD4017
Lisa Germano — Geek the Girl

My Secret Reason, Trouble, Geek the Girl, Just Geek, Cry Wolf, …a psychopath, Sexy Little Girl Princess, Phantom Love, Cancer of Everything, A Guy Like You, …of love and colours, Stars

 BAD4018
Throwing Muses — Bright Yellow Gun

Bright Yellow Gun, Crayon Sun, Red Eyes, Like a Dog

This post is part of the chronological look at all 4AD releases, year by year.

*) Missing from Spotify.

No Fuss No Knead Yes Bread

No-knead breads have become very popular lately, but the recipes all seem to have some incomprehensibly complicated steps (involving folding the dough and a pre-heated pot) in the middle.

So I thought I would try to just bypass those and see what happened, and the results were just as good. And a lot less work.

I don’t think it gets much simpler than this recipe.

There’s just four ingredients:

  • 500g (4 cups) wheat flour
  • 4dl (1.7 cups) water
  • 1/4 tsp dry yeast
  • 2 tsp salt

Put the flour into a bowl.

Add the yeast.

Add the salt.

Stir a bit.

Add water.

Stir until it’s formed a dough, which should take long. You’ll get a moist, sticky dough if the flour/water proportions are right.

Let the dough stand in the bowl for about 18 hours on the bench, covered by plastic wrap or something.

It’ll have risen substantially after 18 hours…

… so beat it down a bit.

And then transfer…

… into a lidded pot that’s lined with baking paper. It should be a pot that can survive being in a 250C (480F) oven for a while, so all-steel or iron is great.

Put the lid on and let it proof for another 90 minutes on the bench. Removing excess baking paper might be a good idea, because they’re usually not rated for that high a temperature and will brown up and become very flaky.

After 90 minutes, the dough will have a-risen again.

Pop it into the lowest rack at 250C (480F) and let it bake for 25 minutes with the lid on.

After 25 minutes, it’ll look like this: Completely pale.

(And remember that the pot is going to be really, really hot at this point, and it seems so natural to instinctively grab the handle — so always wear protection on your hands.)

Take the lid off and move the pot higher up and bake for about another 25 minutes; until it’s how brown you want it to be. Lower the temperature to 210C (410F).

Oops! I forgot to take it out in time, so it’s a bit on the burnt side.

But not seriously. It’s still moist and very wheaty and glutinous: Gluten makes bread nice.

That’s the basic recipe. If you want more fibre, replace some of the wheat with dark rye, for instance, or grind up some nuts and add those: It’s difficult to fail completely with this method. The bread will always come out fluffy but satisfying, and with a nice crust.

Paperlike HD

Since the first time I heard of e-ink products, I was pretty enthused: Imagine having something with the resolution of paper and the convenience of a very light tablet to read from! What a marvel!

And then I saw an e-ink e-reader.

They’re horrible! The resolution is way less than paper, and when you flip the page everything blinks and inverts and dances around!

Seemed like a bad joke to me, but I assumed that surely they’d get their shit together and then one day e-ink e-reader products would take over.

Then years later, not much has happened, except that e-books have fallen in market share as people are moving back to paper books. Because those e-readers are horrible.

So, of course, when I read that somebody had made an HDMI e-ink monitor, I had to have one.

Because I’ve got an Emacs-based alarm clock in the bedroom, and the light from the screen is annoying. Even the OLED screen I bought isn’t black in the black parts. And its response curve goes from, like, #202020 (as black) and then jumps to #808080 as the next-darkest colour it can display.

The e-ink display emits no light, so perhaps it can be used here?

The manual from Dasung is pretty funny. “It should be said that Paperlike is an innovative product with high courage and honesty.”

“Video display and gameplay shall be prohibited.”

I mean, I know what they’re trying to say: That this isn’t a perfect product, and that there are severe restrictions to what you should expect this thing to do. Because of ghosting and the other problems this tech has.

It’s a thoughtful product. For instance, you need just one cable: It’s a mini-HDMI connector at the screen side, and at the computer side it’s a full HDMI and a USB connector for power. Perfect.

So let’s look like what the screen looks like:

Yup, that’s some severe ghosting, alright.

And this is what it looks like when it’s displaying nothing. Not a screen to display secret things on for sure.

But there’s a “C” button on the screen that flashes to white, and then back to black, and then all the ghosting is gone:

Nice. And it’s supposed to be possible to control this from software, too, so perhaps this is usable as an alarm clock…

It turns out that this screen has several modes for doing conversion from colour/greyscale to black and white, and one of them are based on dithering. You get kinda fun effects by dragging things over the images, so it’s half the real image, half after images, and…

And whatever’s happened here? Kinda solarised? Cary Grant looks very sci-fi.

Wow, that’s really out of focus, dude.

ANYWAY.

The software-refresh thing is available on Linux, so kudos to Dasung for that. However, it doesn’t work on Debian, only Ubuntu. And it’s not a command line program, but a GUI. However, it does bind a “hot key”, so I could definitely work around that by just sending the program some software-emulated keys.

The software refresh isn’t as thorough as the hardware button… and the program uses 100% CPU while running. Dasung hasn’t made the source code available, either, and people are trying to decompile it to figure out how to work with it.

What to do…

OK, let’s just try to use it without the software and see what it looks like.

So I plop the new little computer into the Box Of Electronics in the bedroom…

And… Hm. There’s definitely refresh issues, but not quite like I imagined. You can see the missing “08:00” (that was there before), but the time itself is very clear?

Oh, yeah. If you stare at it really hard, you can see the “8” that has been where the “9” is now, and if you stare even harder, you can see the faint ghosts of other numbers.

That’s not bad at all, I think?

Uhm… I found this connector in that box… it’s an… HDMI to DVI to DVI to HDMI connector?

Yes! Useful!

This is what it looks like from some distance. Can’t really see the ghosting at all. Nice!

But then I tried to use this thing tonight, and it turned out that I couldn’t really make the clock out… because it’s too dark! Duh. So I need some lights that I can flick off and on.

Do USB-based lights allow that? It depends? Seems like only very specific hubs has support for this stuff? Are there any USB lights that you can program? That like expose a serial interface you can say “off” to? No?

For now, I’ll just use a small Ikea lamp and control it via the Tellstick interface.

There! I have the on/off light switch by the bed, so perhaps this’ll work… Perhaps a light that can be mounted on top of the screen would be better, but there’s some glare from the screen, so I’m not sure whether that’ll work. Worth a try, though.

I’m going for a Designers Republic kinda vibe with the design. What you’re looking at is, of course, an Emacs buffer, but I’m using SVG to get things lined up better now.

I mean, not lined up. But better.