Some Bits: Nelson's log

57 posts about windows

Remote game streaming

Some things I’ve learned about playing games by running them on a big computer and using my TV as a client. Basically this is an optimized form of desktop screen sharing.

The client TV is a 2160p Sony Bravia. That runs Android and seems the best of the smart TV platforms. The server running the games is a desktop gaming PC, I’ve tried both Bazzite Linux and Windows. Both devices are wired on the same LAN. (This stuff works on the Internet too and is surprisingly responsive.)

Steam Remote Play

Valve has had a remote gaming product for some 10 years. I still have working Steam Link client hardware! But these days it’s easier to run a Steam client on the TV.

It works pretty well but is surprisingly flaky. The biggest problem is resolution switching. Steam should change the desktop resolution to the TV’s resolution, or down to 1080p if I tell it to. That only works one time out of three so mostly I have to change the resolution on the PC myself. (The TV can display anything, but 3440x1440 looks terrible on a 2160p display.)

The other knock on Steam Remote Play is that it’s not very optimized. Folks report 20-40ms latency, or maybe 2 frames of a 60fps game. I haven’t really noticed that but I’m not super sensitive to it.

Sunshine / Moonlight

The alternative fancy gamers recommend is the Sunshine streaming game server and the Moonlight client. These have been around quite awhile, started as an open source reimplementation of the NVidia Game Shield protocol. The big advantage folks quote over Steam is latency: it delivers 4ms on my LAN, or well under one game frame.

The server works well on Windows. It seems reliable. It has some nice stuff about launching things when a client connects, like invoking Steam Big Picture. I’m still having to set the Windows desktop resolution manually although I think Sunshine can do that for me.

The server does not work for me on Bazzite Linux. It sort of does. But the NVidia drivers on my old 1080 card aren’t correctly detecting display modes so I’m stuck streaming 3440x1440.

Alternate resolutions

One dumb thing about all these solutions is that they’re displaying what’s on the PC’s screen, at the PC’s resolution. But basically I have a remote screen on the cliente TV: why should I care what’s plugged in on the server?

One solution is a dummy HDMI plug. This does the EDID handshake to make the computer thing you have a monitor plugged in so you can configure the OS to use it as a primary or secondary screen. These are particularly popular for headless machines: with no monitors plugged in some GPUs refuse to operate at all.

The dummy plug seemed to work as a second screen on Linux. But caused all sorts of problems. First, the desktop GUI wants to use that screen! But it’s invisible, so stuff gets placed there you can’t see. Second, I couldn’t reliably get all the gaming stuff to happen on that fake screen while leaving my desktop alone for normal stuff. The software is just not designed to do it.

I went down a rabbit hole of trying to fix the resolution-switching problems on Linux with my 1080. Total disaster. There’s some hack with kernel keyword arguments with display mode lines, yuck! There’s also a hack where you load fake EDID data from a file to trick the graphics card. I couldn’t make any of that work. Honestly why doesn’t the NVidia driver just detect the modes that are there?

The other solution is a virtual display. Basically have a device driver fake a viritual screen disconnected from actual hardware. This feels like the right solution and reminds me of the ancient X11 virtual desktop hacks. Ironically, virtual displays are reportedly unreliable to impossible on Linux.

On a Windows server folks recommend Apollo, a Sunshine fork, which has virtual displays as a headline feature. I’ve tried this server and it works, but I haven’t tried the virtual display feature yet.

HDR screenshots on Windows

tl;dr: if you’re using HDR on Windows you probably want a new screenshot tool. Bandicamera seems to do HDR reasonably well.

I’ve got HDR10 on my Windows machine working. I like it! Everything looks normal and bright and then occasionally some very bright image comes along that’s even brighter and looks quite striking, a highlight. It’s particularly fun with photos: most photos are normal 8 bit color but a 10 bit comes along sometimes on Instagram and everything comes to life. Also your eye is a marvel, it quickly adjusts to the extra brightness so nothing looks too bright, just more dynamic.

Anyway, making a good screenshot from Windows in HDR mode proves to be hard. The underlying problem is screenshots tend to be 8 bit PNG or JPEG, so you have to collapse the 10 bits down to 8 bits. Ordinarily those brighter 9th and 10th bits aren’t needed, you’re only screenshotting normal SDR images, so often you can just take the ordinary reference white #ffffff as the brightest white in the output #ffffff and it’ll be fine. But that doesn’t work well if there is an overbright part in the screenshot.

Why not take 10 bit screenshots? You can, but you have to save them as an unusual new PNG format or in JPEG-XL or something. For my purposes I usually want a normal 8 bit PNG or JPG.

Anyway, on to the tools. Here’s two test webpages I’m screenshotting: a page with only regular images on it and a page with an eye-searing HDR on it. The key thing I’m looking for here is in the SDR image the white is #ffffff, white. That’s my most important use-case. It’d be nice if the HDR

Greenshot

Greenshot is an old free screenshot tool that is easy to use but quite old fashioned and doesn’t seem HDR aware at all. It seems to do be doing my naive thing: assume all images are 8 bits and just sort of crush any brighter images down to white. The white background is #ffffff like I want, but then any contrast in the HDR part is blown out to white.

Update 2026-03-31: I didn’t describe the problem with Greenshot, which is sometimes even with SDR images if you take a Chrome screenshot it makes everything brighter and wrong.

I can’t figure out what’s going on. Sometimes it works, but if I open a second SDR tab in that Chrome window then the first tab stops working.

There’s a solid bug report for this problem and an experimental fix. Unfortunately even with this fix enabled I’m still seeing problems.

Windows Snipping Tool

The built in-snipping tool can be HDR aware, the tool has an option for “HDR screenshot color corrector”.

With color correction turned on, the good thing is the extra bright parts are brought back into the normal gamut so you can see the contrast. But now the plain white is crushed down to #e1e1e1. That’s necessary for the HDR source image, how else could you have brigher-than-white? But it is not good for a fully 8 bit SDR source image.

With the correction turned off the HDR source ends up blown out just like on Greenshot. But weirdly the SDR source also looks wrong. The white is #ffffff in the screenshot, so great! But it’s hard to see but the snipping tool also brought up the brightness of everything else a little, it doesn’t look what is on the source screen. (Indeed you can see this happen: a tone curve is applied when the screenshot starts being taken).

Bandicamera

Bandicamera is new to me and claims to be an HDR-aware screenshot tool It seems to do a pretty good job.

I like this! The SDR source comes out as a normal looking SDR image, with white at #ffffff. The HDR PNG is blown out, that’s not ideal, but it’s acceptable. I would prefer the Windows snipping tool output but at least I know what it’s doing. Ironically this is exactly what Greenshot does so arguably this is not an improvement. Note these are the ordinary 8 bit PNGs Bandicamera emits. (They don’t support HDR PNGs with cICP chunks).

However, Bandicamp will also write out an AVIF or JXR file that has the full 10 bit screenshot in it. So I do get a second copy with full data. AVIF support is better than I realized: works in major browsers, Windows Photos is fine with it too. I’ve pasted the AVIF below into Wordpress, it looks correct on my blog’s site to me.

ShareX

I didn’t try ShareX. I’ve never liked it, and the website doesn’t say it supports HDR. I did find this ShareX fork for HDR that may be worth a look.

Update: I tried the ShareX fork. It does just what I want: a normal white-is-white screenshot for SDR content and a tone mapped 8 bit PNG for HDR content. It doesn’t save the HDR original like Bandicamera does. Also the “white” in the SDR is #f5f5f5, not sure what that’s about but I can live with it. I just really dislike ShareX, it’s bloated and complicated.

KDE Spectacle (Linux)

Update June 2026: I switched to Linux desktop! They have a fantastic screenshot tool, KDE Spectacle. It currently doesn’t support HDR screenshots. It does a good job with the HDR content on screen though, and screenshots of SDR content look correct.

Passkey success (Jul 2025): 1Password

I love the idea of passkeys but had a very bad time trying to use them last year. But sites keep adding support for them and friends reported they were having more luck, so I gave them another try. It worked!

Before I get into details, I want to talk about another milestone: Apple is leading the way in passkey migration, see these notes on iOS 26. So far none of the vendors had any story for “what if I want to move my passkey to a different device or program?” and Apple now has a solution.

For now I’m storing all my passkeys in 1Password. They’re my existing password agent and I like they are independent. If I were starting brand new I might use Google’s password manager instead, it’s now quite good, but it locks you into Chrome. Apple also has very good password management in their products.

1Password, Windows, and Android

I’m now able to log into GitHub and this test site with passkeys. I generated them in Chrome on Windows and stored them in 1Password and that worked. I could then use them from Chrome on Android (via 1Password). Hooray!

It’s still a little janky: the 1Password UI integration is not perfect. But it does work. A huge help is everything is now displaying which software is trying to fill in the password: 1Password’s blue keyhole icon or Google’s multicolored key.

It was not easy making this work reliably! It’s partly my fault: last year when testing I did everything I could to disable 1Password. Re-enabling it was not so simple. In Windows it’s straightforward enough, but note that Google Chrome or Windows Hello both might try to intervene. I’ve got it going to 1Password first now and I’m happy.

In Android it’s a total mess. It’s Google’s fault, the Android settings have proliferated terribly across the product. And I suspect no one at Google is mandated to make it easy for their competitors to work well.

1Password’s instructions mostly got me there but shed a tear for step 3 with four different scenarios like “If you have a Samsung device running...” Good ol’ Android :-(

Actually even following those instructions I had a lot of trouble. You have to enable it in two different Settings places.

I ended up having to remove everything and re-enable 1Password a second time for it to work. Like I said before, I did a bunch of stuff to disable 1Password last year and I suspect that made me a trickier case than most users.

So passkey usability still isn’t great. But at least I can get them working on my devices now! And now that it is working I’m anticipating a real improvement in authentication usability. I’m convinced passkeys are a good technology, I just wish the user experience were better.

Making Adobe Acrobat not open PDFs downloaded in Chrome

This problem was driving me crazy: Adobe Acrobat was opening PDFs that Chrome downloaded despite every setting I could think of in Chrome or in Windows. This was blocking Chrome’s own PDF reader. Also Sumatra, my favored PDF reader.

The solution is in Acrobat’s preferences. Menu > Preferences > General > Basic Tools > Open PDFs automatically in Reader when they are downloaded in Chrome browser.

I have no idea how an Acrobat preference could be overriding Chrome. I blame Windows, Microsoft built a bunch of hijacking stuff in to Windows to boost their browser. I suspect Adobe is exploiting some thing in Windows.

Adobe is also using malware tactics to reinstall itself as a Chrome extension every month or so. Chrome won’t actually run it, but you do get nagged to use it.

Adobe: 20+ years of terrible, hostile software.

VPN services for Windows in 2025

With the recent anti-porn laws I know a few gentlemen in Texas and Florida with a newfound desire to use a VPN service. I don’t really use a VPN but would like to be of help, here’s what I learned. I’m keeping an eye towards simplicity for non-tech-savvy folks. This post is uncompensated, I am not selling VPNs or profiting in any way from what I’m writing here.

tl;dr: try Proton VPN for free.

Wirecutter recommends Proton VPN or Tunnelbear for free VPN and Mullvad, TunnelBear, or Proton VPN for commercial VPN. The other common VPN service I see recommended is NordVPN. I’d also consider Mozilla VPN, they are reselling Mullvad.

Avoid any other VPN service. Many of them are sleazy or scammy. A VPN gets to see all your Internet traffic and can profit from or subvert you in various awful ways. You must trust them.

If you use a VPN regularly you should expect to pay about $60/year for the service.

Of the reliable services, the main difference is their charging model and free service (if any). Proton VPN has a genuinely free tier you can try first with no payment details. NordVPN has a 30 day trial but you have to give payment details up front (and ask for a refund if you cancel.) Mullvad has no free trial but you only have to pay 5€ for one month to try it. TunnelBear has a 7 day free trial, not sure if it requires payment details to try.

Proton VPN, what’s the gotcha?

I was surprised Wirecutter recommended Proton VPN as an unlimited free service, I didn’t think any free VPN would be worth trying.

I set up Proton VPN on Windows and it seems to genuinely work. The installer has a bit of up-sell, installs of other Proton products. But you can opt-out. Also Proton’s a reputable company, the products they’re offering are reasonable.

The VPN is fast. I tested from my gigabit Sonic fiber and Cloudflare’s test got me up to 800Mbps / 600Mbps with zero packet loss and 31ms latency. Compare 900/800 and 5ms without the VPN. Honestly this result is very good, way better than I expected for a free service.

So what’s the catch? Wirecutter notes you can’t choose which country your egress is in. I was limited to US only. Fine for me but if your goal is to look like you’re in some other country to watch foreign TV, you’ll need to pay. I have to think there’s some other hidden limitations with the free service, I’d assume if I’m making heavy use of Proton VPN I’d end up paying for it.

Proton VPN seems to work via UDP Wireguard by default but has other protocol options. My connection ended up in Seattle at Datacamp (AS212238), with IP address 149.40.62.22. There’s some nice advanced features for split tunneling, DNS management, port forwarding, etc. All paid features.

Overall I’m impressed with Proton’s free service. Maybe there really is no major gotcha, it’s just an honest loss leader.

Windows screenshot tools in 2024

It’s 2024 and Windows is still bad at taking screenshots. Actually the built-in Snipping Tool is sort of OK but third party solutions are better. Also my Apple keyboard doesn’t have a Print Screen button so all the defaults are awkward for me.

For years I’ve used Lightshot but the last release was 2009. Then I used ShareX but never liked it’s complicated UI.

Greenshot is my new bae. It’s open source and has a good UI with some attention to usability and simplicity. There’s a simple built-in editor. I could suggest some minor UI improvements but basically it’s fine. The one feature it’s missing is WebP support but I can easily convert manually with File Converter.

Relationship with Greenshot ended. Turns out it has a serious vulnerability over a year old that is actively being exploited. The release hasn’t been updated in 7 years. The developer keeps making noises about wanting to put out a new release but having trouble with signing keys, etc. IMHO it’s irresponsible for them to keep offering the software if they can’t fix it. I regret recommending it.

Flameshot is also nice with a capture UI that looks like the old Lightshot UI. But there is no way to change the hotkey from PrintScreen and the three year bug report discussion left a bad taste in my mouth. In general Flameshot seems to not have quite the usability polish of Greenshot, and since I can’t even launch it with my keyboard I won’t use it.

Flameshot’s last release was 2022. There’s been a lot of submitted improvements since then but no release on Windows.

Booting Windows 11 23H2 to Steam Big Picture

I want my new TV gaming PC to boot all the way in to Steam Big Picture with no keyboard required. This is remarkably difficult and all the docs you find are outdated because Win 11 23H2 changed some things. Microsoft really doesn’t want you do this. Partly for good reason (it removes local system security) and partly because they are trying to force you into their monopoly experience.

This worked for me:

1. Log in locally, not with Microsoft account

Settings > Accounts > Your info has a “Sign in with a local account instead”. Turn that on.

Documented here, at least until Microsoft hides the docs again. When I did this I got warned I needed to back up my Bitlocker encryption key first, I guess because ordinarily that’s stored in your Microsoft key. I just removed Bitlocker entirely instead.

2. Re-enable the “no password” UI option

Go in RegEdit to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\PasswordLess\Device and set the value DevicePasswordLessBuildVersion to 0. (Mine was 2).

This is a new thing in 23H2, documented here. If you don’t, the next step won’t work.

3. Enable passwordless login

Run the program netplwiz. Uncheck the checkbox at the top for “Users must enter a user name and password to use this computer”.

Documented here. This doesn’t work in 23H2 if you don’t do step 2 to re-enable it. Why the stupid program name? It started life as the “Add Network Places Wizard”, terminology from Windows 95.

4. Get Steam to start at boot in Big Picture mode

Go to Steam Settings > Interface. Enable “Run Steam when my computer starts” and “Start Steam in Big Picture Mode”.

Documented here. The web has all sorts of complicated docs with registry edits, batch files, replacing the Windows shell, etc... None of that is necessary.

Windows gaming PC

On a whim I bought a MinisForum UM690 Pro (Venus), a small form factor PC to use for light gaming on my TV. It’s fairly beefy for a small box, AMD 6900HX processor, Radeon 680M graphics, 32G of RAM. All for $430 on Amazon. More than double what I paid for the N100 server I bought last year but this was the cheapest I could get for what I wanted. My metric here was something with a real GPU, not just integrated. Then I kept bumping up the price a bit to hit the sweet spot of price / performance / newness. I also picked a dual LAN model in case I want to repurpose it as a router.

Hardware

The hardware seems pretty good. My only complaint is that the fan comes on pretty quickly and is not as quiet as I’d like. It’s nothing terrible, not like the vacuum cleaners of old, but it’s definitely not silent. The BIOS makes it look like there’s two fans maybe?

The GPU is OK but not amazing, benchmarks and specs put it at ⅓rd of a Radeon 1080 or 2x a Steam Deck.

At full synthetic load the system pulls about 90W. CPU is at 80°, GPU is at 60°. Fan is noisy but not awful. During normal light use it’s about 30W and the fan is a very quiet hum. 60W playing DRG: Survivor, a light 3d game. Idle is 10W and full sleep mode is 1.5W. It’s not great thermal engineering but it seems to do the job.

Update: the fan is annoying, it seems to come on in short loud bursts instead of a slow steady growth, even under constant load. Unfortunately there’s apparently no way to read or control the fan speed in software. Over on Reddit there are folks complaining and talking about replacing the hardware’s fan with something connected to USB they can control. See here for instance.

I have a beloved Logitech K830 wireless keyboard/mouse that I’m using with it now. Curious about weirdo keyboards like this one: obviously no good for regular typing but enough for pressing a few buttons to log in or launch something. Update: I ordered a Fosmon Mini Bluetooth keyboard.

For games I’m using an old Xbox controller with the unobtainium USB dongle. The pairing is flaky and won’t wake the system from sleep. I gather Xbox controllers are still the best choice for PCs. 8BitDo also makes good controllers for cheaper, I’ve pre-ordered the Ultimate 2C. Note there’s a feeling you’d rather have proprietary wireless because Bluetooth has high variable latency.

Windows 11

Windows 11 sure does not spark joy. There’s so many upsells and manipulations from Microsoft I feel like I’m fighting a war. OFGB is a help with that. I was originally going to reinstall Windows because I wasn’t sure I trusted whatever MinisForum installed but it seems fine. No bloatware at all. It does come with a Windows 11 Home license so that’s a bit of a nuisance, I’d really like Pro so I had remote desktop access. I may yet buy a cheap license key to upgrade.

I had a brief moment of excitement when I flashed the BIOS and it rebooted demanding my BitLocker key. I guess the drive is encrypted? I had no idea what the key might be. Fortunately Microsoft has a thoughtful recovery system, the BIOS displayed a URL to visit and I found my key there in my Microsoft account. All this stuff requires networks and logins of course but these days I just accept that’s the thing.

MinisForum has a nice driver distribution in the support page. Nothing too exotic, mostly it’s just AMD drivers. The only problem I’ve fun into is nothing seems to be able to read the fan speed. Hardly a big deal.

Software

I’m resisting the urge to install too much on this machine. Keep telling myself it’s for games, not a real working machine.

Steam, of course, for games. Its Big Picture mode is really nice. I haven’t yet figured out how to get the computer to boot into this mode, it may not be possible since Windows really wants you to type some sort of login PIN or something when the computer starts. That also means I need to keep a keyboard around, ugh. (“Local only account” I think is the solution for the PIN but I haven’t tried it.) Update: I set up autologin, notes here.

Playnite is an interesting alternative cross-platform game launcher. I gave it a quick try and I think I’ll stick with Steam. Playnite is interesting if you are playing a lot of games from other sources. The UI is pretty databasey though and it lacks Steam’s great “show only controller games” filter. Also doesn’t seem to fully support controller itself although it does in full screen. I do like how it uses IGDB though.

I’ve also installed UltraVNC for remote access. It’s clumsy software but does seem to work. The remote access world has gotten real weird, there’s a zillion different products out there that all seem a bit sketchy. VNC is still alive and well, TightVNC is the other one that comes recommended. RustDesk also looked interesting to me for something new.

Update: RustDesk seems to perform much better over LAN. All of them have bugs, like you can’t reliably resize windows on the remote desktop. (Alt-Space > Size helps with this.)

I installed Controller Companion. It’s a $3 Steam app that lets you use a game controller as a keyboard and mouse replacement. The mouse is great but the on-screen keyboard is clumsy. But it does kind of work and seems useful. It’s nearly abandonware: the last real work was in 2017 and the last update at all was 2020. JoyXOff is a free alternative that had an update in the last year. Steam also can do this itself if you enable Steam Input in desktop (in the controller settings.)

I’m having problems swapping between a running game and other stuff. Big Picture is 2160p and the game is 1080p fullscreen and when I Alt-Tab out of the game, Big Picture is in a window covering the top ¼ only. I think it’s supposed to be full screen though, maybe I didn’t tab to it on top?

I had a maddening problem where games would only run at 1080p 30Hz with vsync turned on. Without vsync they’d run at 120fps, so it wasn’t the GPU not keeping up. Finally figured out Windows had for some reason decided to run the display adapter at 2160p 30Hz, despite all the cables and monitor working fine at 60Hz. Took awhile to figure out: the Very Fancy AMD Adrenaline software that claims to optimize everything never noticed. Neither did Windows, nor Steam.

Windows and voice recognition

Looking for typing accommodations while my wrist is giving me trouble. I love how Google Voice recognition works on Android, you’d think that it would be even easier and better on a desktop PC. But the UI doesn’t quite seem to be there.

Update. I originally wrote this post using Windows 10. Turns out Windows 11 has an entire new thing called Voice Access and it’s quite good, just about what I need. I’ve edited the post to reflect all this, but it’s probably a little confusing.

I’m fortunate that I can use both hands still and mousing gives me no trouble, just trying to take some load off my left hand.

Windows 10

Windows 10 seems to have two different systems for voice recognition. There’s an older speech control system that is mostly focused on UI control like opening the start menu or closing windows. It has some speech to text dictation but the language model is terrible and not useful.

There’s also the newer windows dictation accessible via Win-H. It’s dictation only, not really system control, but reasonably good. However the UI’s awkward. Also the language model is not as good as what I get on my pixel eight. But it is usable.

The biggest problem is activating dictation mode. I have to click in the window I want to type in, then click this weird microphone icon that’s hovering in a fixed width window on the desktop. And even then it does not work reliably. I would dearly love to assign the “take dictation” function to something like a hot key or mouse button four. Haven’t found a way to script that. Quick searches make it look like it’s not possible.

I had thought Microsoft put more work into usability. The full speech control system does work, but it’s pretty awkward and is something you would only use if you had no alternative. And the fact it’s basic dictation speech model is no good makes it useless to me. Maybe it’s better in Windows 11? I think the full control Voice Access system is much better.

Windows 11

Microsoft did put more work into usability! Windows 11 is significantly better. The old speech control system that I didn’t like is basically gone. Windows Dictation has been extended to Windows Voice Access and gives you fairly reasonable control over the whole UI.

For my purposes, the most important thing is that the speech to text in the new Windows voice access is much better. The UI is also better. You can basically leave it running all the time, no need to press a button to activate the microphone every time you need it. It doesn’t do anything until you start talking. Then it will just insert what you say as if you typed it. That means I can leave the thing running all the time. And when I have something more extensive to say, I can talk instead of type. (Although it seems like it picks up audio from the speaker so that’s a little annoying if you are playing a video with someone talking.) The speech model is pretty good, other than the automatic punctuation system which I’ve had to turn off. Totally usable though, it’s closer to Google Board speech detection than not.

There’s a good little voice control demo that I ran through and I’m impressed that I could actually use this to control a PC with my voice if I’m patient enough. It works by you speaking voice commands. It has some generic controls for clicking named buttons or narrowing in on a region of the screen to click on. It also has some specific app integration. For instance, “close tab” seems to be something it understands explicitly to close tabs in a web browser. It doesn’t work in Chrome but it works great in Edge. Maybe Edge has extra code to interface with voice access? One drawback is there is some ambiguity. If I start a sentence with the word start or close it may interpret it as a command and not me trying to type those words. There is a dictation only mode but I haven’t figured out how to turn it on (saying “switch to dictation mode” should do it but does not for me.)

Voice In extension

Now I’m wondering why Chrome on desktop doesn’t have voice typing. It seems like it would be easy to build it into the browser. I’m finding some third party hacks like Voice In.

I gave Voice In a try and it seems to mostly work and be a lot simpler trigger than the windows built-in thing. You can bind it to any windows hotkey but in Chrome that means control or alt + a letter. I really want just a mouse button. I probably can use Autohotkey to make that happen. Being a Chrome extension makes it pretty limited but then also probably easier to integrate.

I gave it more of a try and it’s mixed results. The language model these things recognize to is so important. I was writing an email to a friend about gay stuff and it kept missing very basic words that would be common in a gay context but not in some other. Also it has a habit of capitalizing random words like extreme or City. Mostly it just made me wish I could use Google Voice typing model because I am very good at getting what I want to out of it.

Having the extension be Chrome only is a little irritating particularly when I switch to slack. I guess I could run slack in the browser. The free version works reasonably well but really you’re going to pay $60 a year if you use it all the time. It’s not a big problem not having a keystroke to activate, mostly you just leave it active all the time.

Google could absolutely build a good Windows desktop or Chrome product for voice typing. I suspect the market just isn’t big enough for them

Passkeys try two

Yesterday I tried using passkeys with Google and had a bad experience. I’ve since found a couple of sources of the problems and worked around them. I will reiterate it’s still all a bad experience, in no way is this product ready for ordinary users to rely on.

Some of my passkey problems may be specific to logging in to Google services. There seems to be something wrong specifically with their server-side authentication implementation, maybe related to the “new login page” they recently launched. I’m having a better experience with other sites. With both GitHub and Adobe I’m able to create a passkey, save it, and use it to log in. Sometimes. Chrome seems to be sending passkey requests to the wrong device.

Some of my problems might also be related to 1Password. It’s in the middle, between the authenticating site and my browser. But I really want passkey requests to go through to Google’s passkey agent on my phone (at least until 1Password works on Android). See below for notes on 1Password; I’ve disabled its passkey support in my desktop browser for now.

The main problem I’ve encountered is which agent I store the passkey on. I have at least four possibilities: 1Password, Windows Hello (on my desktop), my Pixel 8 Android phone, and my Samsung Android tablet. Those latter two are the same data store, with passkeys synced, but separate physical devices. I want to use the Pixel 8 because it’s the most likely to be accessible to me, at least until 1Password works reliably on Android. But it’s seldom the device I’m logging in on, so I’m relying on Chrome / Windows delegation to a nearby device.

Saving a passkey

This is what saving an Adobe passkey looks like. Before I turned off 1Password, Chrome on Windows wanted me to save the passkey in 1Password, that’s the screenshot above left. If I click the little Yubikey looking thing at the top then I get brought to a Windows dialog in the middle: this is asking me to save it to Windows Hello on my desktop, as authenticated with a PIN. If I then click “Use another device” I get the option of using my Pixel 8. That works; the Pixel gets a message (Bluetooth? Internet?), pops up a screen, and I can save the passkey.

Logging in with a passkey

Logging in worked for me, at least once. But as I tried to document this more thoroughly it failed. I finally turned off 1Password’s recommending passkeys in the browser and that seems to have simplified things enough where they work reliably.

That slideshow is the easy seven step process that’s working for me to log in. I believe steps 1 and 2 are Adobe’s website, 3 4 and 5 are all Chrome on desktop, and steps 6 and 7 are Windows. Not depicted: the extra steps for the UI on the phone to actually use the passkey.

Things go really wrong between steps 3 and 4. I say “Use a passkey from Pixel 8” and then the browser sends the request to SM-X800 instead. That’s my Samsung tablet. WTF? Google knows I’m logged in to two Android devices and syncs passkeys to both of them. So in theory either device would work but I have the phone with me always, not the tablet. And it’s wacky that I am prompted for “Pixel 8” and it sends it to “SM-X800” instead. The passkey dialog sometimes shows up on the tablet but when I’ve tried using it it fails (now it’s not even showing up). I can’t find any way to tell Google to use my Pixel 8 exclusively, or preferentially. I asked on Reddit.

So instead of step 4 I do steps 5 and 6 instead, the awkward way to get Chrome/Windows to use another device for a passkey instead of the default. Note the UI stops being Chrome and starts being Windows at step 6. The good news is this does work; the passkey dialog shows up on the Pixel 8, I approve, and I’m logged in.

Mind you this 7 step process is the good case, I have it working reliably and repeatedly. But only after disabling 1Password entirely and only after going through contortions to work around some problem with using the wrong passkey device. Still not sure how that is happening.

Update: really helpful response on Mastodon from a Google engineer saying at least some of what I’m encountering with multiple devices could be a bug in Chrome.

1Password

I’ve only gotten this far by disabling 1Password’s passkey support entirely. It looks like this:

I’m sympathetic to 1Password, it must be very hard to preserve your business when dependent on the platforms of monopolists. I want them to be my passkey store. But until 1Password works on Android I can’t. And the Chrome desktop browser integration on Windows seems to be causing me problems. Not sure if it’s outright bugs or if it’s just some things are simpler without it.

Anyway, here’s the 1Password extension preferences and its confusing array of options for exactly where it will intervene. As you can see I’ve disabled the most obvious passkey part of it. I still see some evidence it’s in the middle sometimes though. I’m really not sure. Some of my testing has been with the extension entirely disabled in Chrome, I’m reasonably sure it’s not involved in those cases.

Passkeys still awkward in Mar 2024 (Android, Chrome, Windows, 1Password)

Some tech friends surprised me by saying they’re all using passkeys and liking them. I’m still not, despite being very interested in them. Passkeys seem like a failure to me so far. But my friends who are having success with them are all full-in on the Apple ecosystem, that may be why they are having a good experience. I’m using mostly Google and Android stuff and really want 1Password to manage my passkeys.

Update: the notes below are mostly for trying to log in to Google using passkeys. I had a better experience using passkeys for GitHub.

1Password passkeys are a mess.

1Password doesn’t work. I’m not sure it’s their fault. The platform owners (Google, Microsoft, Apple) have all paid lip-service to supporting third party passkey stores but in practice it is clumsy if it works at all. 1Password announced support for passkeys last September, including Android. But here in March 2024 it still doesn’t work. It requires Android 14, which came out only 5 months ago and isn’t on many devices. It also requires Chrome support third party passkeys. Which maybe works? But requires setting a flag in Chrome to enable, and user reports say it may not work well. Disappointing all around and also a clear question for anti-trust investigation IMHO.

The Google passkey experience

Using passkeys in Google (Android, Chrome) is better but doesn’t work reliably. I successfully just created a passkey stored on my Pixel phone, in Google’s store. And then logged in with it using my Windows machine running Chrome. But I had to scan a QRCode to do that, an absurd workflow, despite my phone and my desktop communicating (via Bluetooth?) in the past in some Chrome thing. In theory this desktop/phone integration gets better the second time you need it but instead it just doesn’t work at all; the desktop browser tells me to press a button on my phone but the prompt never shows up on the phone. A similar workflow for Google 2FA is still working so my phone is still able to do some authentication related stuff.

Also I can’t reliably use accounts.google.com to manage my passkeys. Google’s webapp crashes. It might be related to my browser extensions, it works better in incognito mode. Or it’s possible this is something unique to me (I have one of the very first Google accounts ever, created when I worked there before anything launched). Or maybe it’s just broken?

None of this is giving me much confidence in Google managing passkeys.

How about Microsoft?

I also tried creating a passkey stored in Windows Hello to log in to Google using my Chrome browser. This actually works pretty well. But Windows Hello feels rinky-dink and I really don’t want to use it. And at least some part of Windows integration breaks.

Migration

Another huge problem with passkeys is there’s still no story for migrating. If I have a passkey stored on my phone and I get a new phone, can I move the old passkey to another phone? What if I switch from Android to iPhone? Every time I’ve looked they say “migration is a work in progress”.

The practical thing for now is to look at passkeys as ephemeral things you have many of. Your account at Google has many ways to log in: password, proprietary device-based unlock, passkeys. It might have several passkeys. If you get a new phone you’ll just make a new passkey.

Except... what if I use passkeys to log in everywhere? What if I have 100 passkeys on my phone? Do I manually have to create 100 new passkeys, one for every site? That’s ridiculous. But I think that’s where we are today.

Which brings me back to 1Password. They have an excellent story for migration; your authentication lives in the 1Password cloud. Or at least I think they do, I’m not actually sure for passkeys. I can’t test it. Because 1Password passkeys don’t work in Chrome.

Update: it seems Android is storing passkeys in the Google Password Store which you can manage via the Chrome browser. They are synced across devices.

Windows fan speed controls in 2023

Computer fan noise was annoying me in my office, this high pitched whine. So I went looking for Windows software to understand what my desktop was doing.

LibreHardwareMonitor is a good open source program for monitoring fan speeds. It’s a fork of OpenHardwareMonitor, which stopped getting updates in 2020. You just run it and it quickly gives you a list of fan speeds, CPU temperatures, and a bunch of other hardware sensors. It has support for a whole lot of hardware and requires precious little effort to get going.

Usually a PC’s BIOS controls fan speeds. My ASUS X570 has a fancy thing called Q-Fan which has little control graph settins of fan speed vs temperatures. This works pretty well. My vague memory is if you run the “Optimize” thing in the BIOS once everything works better, but you still want to tweak it manually afterwards. (Bonus memory: the Apple keyboard I usually use is not capable of opening the BIOS with F2/Del. Something weird about how it initializes, or rather doesn’t. I have to plug in a standard PC keyboard to open the BIOS.)

Fan Control is an open source program to override the BIOS’ fan settings. If you ever used the ancient SpeedFan program, this is a better version of the same idea. It has a very slick setup system where it enumerates all the fan controllers, then tries changing input power and then sees what the fan RPM sensors tell it happened. Once it’s set up you can then manually alter fan speeds (overriding the BIOS) or enable one of several “Curves” which automatically change fan speed in response to temperature or other sensors. I decided not to use this but if I wanted to do more than the BIOS’ settings, I would.

CPUStres is a Microsoft Sysinternals program to generate CPU load to test your cooling. I found this really confusing to use.

HeavyLoad is a third party program for generating load. It’s no cost but is not open source. it’s easy to use to peg your CPU and GPU to 100%. It has a weird bug where it launches but the GUI doesn’t get events; if you switch to another window and back it seems to work right.

I spent half an hour figuring out what the fans were in my computer.

  • Fan 1: the fan at the back of my computer chassis. Very quiet even at full speed, software controlled. Usually runs at 550RPM, max is about 830.
  • Fan 2: the fan in the middle of the Noctua NH-D15S CPU cooler. This gets a little noisy at full speed (1500 RPM) but usually runs more like 550 RPM. It’s the fan I hear when my computer gets busy and is a little annoying, but sounds like moving air and not a whine. Software controlled.
  • Fan 5: no idea what this is, it shows as 840 RPM almost always no matter how busy the system is. It is software controllable and I can hear it, but I never did quite find where it was. The ASUS BIOS shows an “AIO Pump” running at 840 RPM but I certainly don’t have any pumps or liquid cooling. Maybe someone reused the motherboard header for a fan for the motherboard chipset or something?
  • Mystery 2866 RPM Fan. The BIOS shows me a PCH fan running at 2866 RPM. I have no idea what that would be and there’s nothing running loud enough to be that fast. The speed slightly varies so I suspect the sensor is hooked to something.
  • Power supply fan. My Corsair RM750X has a fan. It has no software interface at all but does turn up or down based on temperature. It seems very quiet.
  • NVidia 1080 GPU fan. Almost always entirely off, gets up to 650 RPM or more when the GPU is busy. It’s pretty noisy when it turns on.

The ironic conclusion to all this: the noise wasn’t coming from my Windows machine at all. But rather the NUC Linux server in the closet. Noise goes away when I close the closet door, d’oh. This is the same NUC that is overheating and is unstable at full CPU speed. The fan does work, I haven’t looked at controlling it.

WinCompose and other ways to type Unicode

I’ve long wanted a good general purpose Unicode input method on Windows. To type so-called “special characters” like ñ or ü or ű. MacOS has a great way of doing this; long-press a key and a popup appears. Both Android and iOS have something similar. Windows doesn’t. I do a lot of cut-and-pasting.

There’s a bunch of Windows solutions that don’t work very well. You can choose an input method that includes more than US English, but that’s intended more for regular typing of one specific character set than the diverse one-offs I need. There’s the ancient numeric keypad method but it requires knowing the Unicode code point number for the character. I’ve tried some Windows programs that emulate the MacOS long press UI but none worked reliably. PowerToys has Quick Accent but the default activation key (space) is too easy to activate by accident.

WinCompose may be the solution I want. It gives you a compose key; you press Right Alt, let go, then type a mnemonic key sequence like ~n to insert ñ. Some of the sequences are pretty arbitrary and there’s a lot of silly macros like TF for “table flip like a boss”: (ノಥ益ಥ)ノ彡┻━┻. But I think I can guess or learn most of the characters I want. One particular thing to remember; a lot of emoji are defined by pressing Compose-Compose and then typing the name of the symbol. Ie Alt-Alt-JOYSTICK to get 🕹️.

One thing missing from the default compose tables is the ʻOkina, the character used in Hawaiian for a glottal stop. Along with ñ it’s an important character for writing US English place names correctly; the state is properly Hawaiʻi, not Hawaii. The character in Unicode is MODIFIER LETTER TURNED COMMA (U+02BB). The question is how to type it.

I’m going with ``, <grave> <grave>, pressing the upper left key that’s also ~ twice. I found that definition on this random site and it seems pretty reasonable.

    <Multi_key> <grave> <grave>                     : "ʻ"    U02BB   # MODIFIER LETTER TURNED COMMA (Okina)

Not sure this is the best choice. <grave> <grave> already has a meaning in WinCompose: “ which is U+201C, Left Double Quotation Mark (also used in kragen’s xcompose configuration). Overriding it causes no problems and anyway there’s other ways to type it: Compose < ” for instance. This X11 man page suggests <grave> <grave> is the beginning of a bunch of Cyrillic characters but those composed diacritics look pretty unusual to me, maybe not essential.. Anyway this is going to work for me.

It’d be nice to have a standard. I filed an issue with kragen’s config opening the question. It seems to be a good place to define some sort of standard.

I should add that the compose key has a long history in Unix computing dating back to the VT220 in 1983. XCompose, the X Windows system for this, is a defacto standard. WinCompose basically implements XCompose and uses the same config file format.

Windows 11: 22H2 and Memory Integrity woes

More boring Windows sysadmin crap, no satisfactory conclusion.

Windows 11 22H2 came out today. I tried to install it. It gets to 37% and fails with basically no useful error message. “Window Update error code 0x80070001”. Thanks dudes. Searching for that error code is not helpful, with a bunch of cargo cult advice for a zillion different things that might be wrong.

I tried using Get-WindowsUpdateLog to give me a text file log of what went wrong but it’s impenetrably detailed. This looks like the error but I can’t imagine what is the actual problem.

2022-09-20 15:37:00.9942721 16468 23084 Deployment      *FAILED* [80070001] file = onecore\enduser\windowsupdate\client\engine\handler\osdeployment\helper\osdeploymenthelper.cpp, line = 612
2022-09-20 15:37:00.9942763 16468 23084 Deployment      *FAILED* [80070001] file = onecore\enduser\windowsupdate\client\updatedeployment\handler\osdeployment\installer\osinstaller.cpp, line = 1157
2022-09-20 15:37:01.0008701 16468 23084 Handler         Install complete for update ID: 8E409263-45B4-438D-AD01-6E9674AB032A.1 Return code is 0x80070001. Requires Reboot:No
2022-09-20 15:37:01.0008721 16468 23084 Handler         Enter deployment handler NotifyResult
2022-09-20 15:37:01.0009405 20108 24312 Deployment      Deployment job Id 51AE112D-2F4D-46DB-A0A4-381CB450EAAE : Update 8e409263-45b4-438d-ad01-6e9674ab032a.1 failure delegate invoked.
2022-09-20 15:37:01.0009697 16468 23084 Handler         Leave deployment handler NotifyResult
2022-09-20 15:37:01.0010261 16468 23084 Deployment      *FAILED* [80070001] file = onecore\enduser\windowsupdate\client\updatedeployment\handler\osdeployment\installer\osinstaller.cpp, line = 356
2022-09-20 15:37:01.0010271 16468 23084 Handler         *FAILED* [80070001] Leave deployment handler Install

So I started trying to figure out what else might be wrong with my system. One persistent problem is Windows Security claims that Memory Integrity isn’t enabled; that’s some virtualization thing to isolate processes. It wouldn’t turn on because an obsolete driver was blocking it. What driver? Some ancient Western Digital thing; I don’t even have any WD hardware on my system. It just got an update via Windows Update which resulted not only in the old version being installed but a slightly newer version also incompatible being installed. Great jerb. Anyway you can manually remove the drivers by using pnputil on the wdcsam files. I have no idea if this could break a system but I chanced it and it worked.

Well, sorta. Now I could enable memory integrity. Then it reboots to install itself and during the reboot I get a blue screen of death with something about Bug Check 0x7E, which means “System Thread Exception Not Handled”. That’s programmer speak for “shit’s fucked up, yo”. Searching online finds other people with this problem with the usual scattershot advice for fixing things and the occasional malware recommendation.

Just before then the event log had errors about IntelHaxm: “HAXM Failed to init VMX” and “HAXM can’t work on system without VT support”. I’m confused about this. I definitely have virtualization support, I’m using Hyper-V for WSL2. I don’t know about VT support. Also wondering if the Intel thing is a problem; this is an AMD Ryzen CPU. This Windows system started life on an Intel CPU and I transplanted the drive to an AMD system. Everything’s worked fine (it installs new drivers for the hardware it detects) but maybe there’s some weird vestige? Or it could be completely unrelated. I give up.

Windows 11: fixing crackling microphone

My headset plugged into my motherboard (Realtek audio) stopped working on my machine, maybe about when I upgraded to Windows 11? Not sure, but when I talked people would hear noise but just a burst of static. The fix was the re-set the format to 2 channel, 16 bit, 44100 Hz.

Windows sound drivers are an absolute mess. The fancy new Windows 11 UI works fine for basic things, but all the important stuff is still hidden in the Windows 7 Control Panel style settings. Why TF hasn’t Microsoft fully ported all the control panel stuff yet? It’s been 7 years since Windows 10 came out and yet still a lot of important settings are hidden in Windows 7 APIs.

In the end I found this guide most useful, using the local “Listen to this Device” loopback, Discord, and Google Voice to test. The web app for Google Voice bafflingly has no microphone playback / test I could find, but if you place a phone call to +1 (909) 390-0003‬ something will answer that will echo calls back to you. (Sadly this number has been tagged “Gateway to Hell” online enough that you might see that name.)

In the end my problem was the microphone device had somehow been set to 32 bits per sample. (This happened two years ago, too.) Which breaks everything not in some coherent way, but by just playing corrupted staticy audio. Nice. Windows is sure doing no favors to ordinary users letting people choose all these formats. 16 bit 44100 Hz is just fine for anyone who isn’t running a recording studio. (Or 48000 Hz; love having two nearly equivalent choices.)

Setting up a second WSL distribution

I want to switch from Ubuntu 20.04 to 22.04 on my WSL system. But I’m cautious, so my plan is to install a second WSL image and move my stuff over. Maybe there’s an easier way, but here’s what I did. Installing a first distribution is easy btw, the trick is getting a second without clobbering the first.

Step 1: install second distribution. I followed the procedure here. It boils down to downloading an Ubuntu cloud tarball and using wsl.exe to install it. WSL’s installer puts distributions in C:\Users\Nelson\AppData\Local\Packages so I put the new one there too.

Step 2: set up a user. The distro from step 1 works fine but you’re root. I followed the procedure here. It boils down to using adduser to create the user, then editing /etc/wsl.conf to make that user the default. Note that WSL configuration changes apparently take 8 seconds to apply.

Step 3: copy over your home directory files. There’s no easy and efficient way to access files from one WSL distro in another. So I went way old school and used tar over netcat for /home/nelson. Sometimes the old ways are the best ways.

Step 4: change default distribution. wsl.exe --default sets this for WSL as a whole; I also had to configure which distribution to launch in Windows Terminal.

It’d be nice if my home directory were a separate virtual disk instead of buried inside the WSL image. Some quick Googling suggests it might be possible but it involves an extra mount process and I worry it might not be 100% reliable. There are ways to access other WSL distributions or files from a Windows folder but they seem to involve localhost network mounts (via 9p) or other inefficient things.

Given WSL2 is just a fancy wrapper around virtual machines it seems like this whole process could be a lot simpler and more explicit. But the WSL team came at this from a different direction; “make a Linux program work just like a Windows program on Windows” instead of “manage a library of virtual machines”.

Windows 11 thoughts: taskbar customization

I upgraded to Windows 11 last night. Finally needed WSLg enough to take the jump. Install went fine and mostly I like the changes. The big visible thing is a UI refresh; nicer File Explorer, cleaned up right click menus on files, etc. It’s mostly good. Apparently rounded corners are in this season along with shorter shorts on men.

And then there’s the taskbar. They completely rewrote it. And stripped out a bunch of features. The one that’s killing me is the taskbar now must be on the bottom; there’s no way to move it to the left. Which is where you want it on a screen that’s much wider than it is tall. Which also means there’s no text labels, something I liked on a wide monitor. Argh!

So that got me looking for customization options. There are a lot. Here’s some I found.

  • RoundedTB: changes the look of the task bar: rounded, and transparent in the empty parts (so it looks like boxes, not a bar).
  • Stardock: Start10 gives you a Windows 10-like start menu (with the Windows 11 task bar). Start11 lets you customize the look of the Windows 11 taskbar and start menu in various ways.
  • StartIsBack: another Start/Taskbar customizer mostly advertising the ability to make it look like Windows 10.
  • ExplorerPatcher is a grab-bag of little changes to various UI elements, mostly to look like older version of Windows. It sounds like this just enables hidden old code, it’s not a rewrite / new Start menu like some of the others. Could be wrong about that.
  • StartAllBack: yet another set of UI tweaks, with Windows 10 style taskbar and start menu. This one is the only one that claims to move the taskbar to the left.

They’re all more similar than different really. Many of these are “bring me back my old Windows 10 GUI” (or even worse, Windows 7). I like Windows 11’s changes in general, I want to go forward, just want to tweak one or two things.

StartAllBack is the only one I installed and tried. And it’s pretty good, I’ll probably keep using it. I’m mainly using it for the “enhanced classic taskbar” which seems to be a rewrite of Windows 10 style task bars. It’s mostly OK and even lets some of the newer features like jump lists through if you want them. I sure missed my text labels for tasks on the left, glad to have them

WSL copy/paste clipboard

Useful command line pipeline tools for WSL, similar to MacOS pbcopy and pbpaste.

To paste the contents of the Windows clipboard into a WSL shell pipeline

powershell.exe Get-Clipboard | wc

To put the outputs of a command into the clipboard

echo foo | clip.exe

That’s the basic version. There’s a nicer version described here or packaged here suitable for installing. It uses sed to strip the DOS newlines and extra newline out of the clipboard content. Also uses tee in front of clip.exe, I think so that it will echo the output back to stdout as well.

Pretty clumsy having to invoke this code! But I believe WSL 2 has no API for accessing the Windows clipboard. It’d be simple enough to imagine in WSL 1’s emulator, but since WSL 2 is more of a VM approach it’d be more work. And then it’d be some weird WSL system call no other Linux understood, anyway. Although... WSL-G must have clipboard support, I wonder if there’s an alternate approach.

mDNS, hostname.local, and WSL2

Modern computers can often be reached by the DNS name hostname.local. This is implemented via Multicast DNS, mDNS, which originated in the early 2000s as part of the zeroconf work to make networked computers usable without manual configuration. Apple’s Bonjour was the first implementation of it I saw working widely. Linux machines tend to use Avahi. For Debain and Ubuntu systems apt install avahi-daemon is generally enough to get the system announcing its name.

The magic of multicast

It works via multicast. mDNS-aware name resolvers know that if a domain name ends in .local, the way to resolve it is to send a UDP multicast request to 224.0.0.251:5353 or and see if anyone answers. (There’s an IPv6 equivalent). Multicast generally propagates across your whole LAN; if a host sees a query for their own name it answers back to 224.0.0.251 (not the requester directly) with a DNS record. It’s not exactly standard DNS packets, some slight modifications in place, but the basics are the same.

It works great! As long as you have a reliable LAN. I’m using it on some Raspberry Pi devices with a flaky WiFi connection and that’s not a good experience.

As an aside, can I say how much I love multicast? Ethernet broadcast too, and even the less common anycast. Being able to send a packet to the local network without being exactly sure who the recipient is can be very useful in all sorts of applications. A lot of stuff we do like NTP would work better if it regularly used multicast. Unfortunately multicast over the routed public Internet is pretty much a dead-end technology; no one has ever figured out how to manage it scalably.

mDNS services

I mostly use mDNS myself for .local domain name resolution. But mDNS is a full service discovery framework. You can use it to ask for things like “is there a printer on the network?”

Avahi comes with a discovery tool to get a quick dump of services on the network.
avahi-browse --all --ignore-local --resolve --terminate
Here’s an example of the services my printer offers

+   eno1 IPv4 Samsung M267x 287x Series (SEC...)   _privet._tcp         local
+   eno1 IPv4 Samsung M267x 287x Series (SEC...)   _scanner._tcp        local
+   eno1 IPv4 Samsung M267x 287x Series (SEC...)   UNIX Printer         local
+   eno1 IPv4 Samsung M267x 287x Series (SEC...)   PDL Printer          local
+   eno1 IPv4 Samsung M267x 287x Series (SEC...)   Internet Printer     local
+   eno1 IPv4 Samsung M267x 287x Series (SEC...)   Web Site             local

On my LAN I have services for Sonos, Roku Airplay, the printer, my Samba fileshare, and some things Home Assistant has published.

I believe the service discovery is all implemented via mDNS queries, with some extra information placed in TXT records. It all looks fairly elaborate, RFC 6763 is one reference for how it works. Now I’m curious how carefully specified the metadata for things like printers are. Is there a clear standard or is it all freeform and customary publication?

WSL and mDNS

WSL2, Microsoft’s Linux VM for Windows, also supports .local domain names. It’s a little weird. My windows machine is named “Nelson-Win10”. On the rest of my network nelson-win10.local resolves to 192.168.3.114, the DHCP-assigned address for the host Windows system. Just like you’d expect. But inside a WSL2 shell it resolves to Nelson-Win10.mshome.net (172.27.48.1). That’s a private-use address and the domain name is something Microsoft has been doing for years as part of their Internet connection sharing stuff. This address is reachable from the host Windows system. It’s not accessible on the rest of my LAN because I don’t have routes for that subnet, I wonder if it would work if I added one? Anyway this is all a workaround for the fact that localhost doesn’t work very well (or at all) across the host Windows and WSL2). Honestly all the networking in WSL2 to the outside world is kind of confusing and maybe buggy. But hostname.local works on the Windows machine itself.

(Note that in a command shell on Windows itself, nelson-win10.local also works. It resolves to an IPv6 link local address in the fe80::/10 block.)

syncthing and WSL 2: running in the background

I’ve been using syncthing a couple of years now and finally trust it to manage all of my source code. Part of that is getting it to sync files on my WSL Ubuntu images. They’re more or less like standalone Linux VMs and need their own syncthing, it won’t work to just sync files on the Windows host system.

Syncthing mostly just works in WSL, no drama. The challenge is that WSL doesn’t have a systemd or cron so there’s no easy way to start syncthing at system boot. Also syncthing itself is not really written as a daemon; if you just run “syncthing” it writes to stdout and listens to signals and stuff. Awkward.

There’s lots of advice on how to deal with this problem and most of it doesn’t work. The real problem I ran into is something weird about WSL, at least the WSL 2 I’m using. This GitHub issue discusses it: even with nohup and other efforts, background tasks launched by wsl.exe will sometimes disappear. You can write a script that looks like it runs a background process fine and test it in Linux and it works. But if you invoke the script via wsl.exe whatever processes it spawned disappear. No, nohup doesn’t help. This is all very mysterious and it’s worth remembering that WSL only started supporting background tasks a couple of year ago.

The solution that worked for me is to use the daemonize program. There’s an Ubuntu package for it. It’s pretty straightforward, it does all the Unix stuff you’re supposed to do for a daemon but don’t bother with (like cd / so that filesystems can be unmounted.)

Here’s the Linux shell script I use to run syncthing. The weird GUI port is because I also have Syncthing running on my Windows host.

#!/bin/bash
OPTS="
        --no-browser
        --home=/home/nelson/.config/syncthing
        --gui-address=http://127.0.0.1:2103
        --logfile=/home/nelson/.config/syncthing/syncthing.log
"
daemonize /usr/bin/syncthing serve $OPTS

The way I launch this at Windows boot time is I have a shortcut in shell:startup that has a target of

C:\Windows\System32\wsl.exe --exec /home/nelson/.bin/syncthing-server-wsl

A batch file might work too.

It’s not ideal. If I’m logged in and just launch the shortcut it works pretty nicely. A command shell window briefly pops up and disappears; if that annoys me enough there’s kludges to workaround that.

There’s a bigger problem on system startup: the console window pops up and hangs for ~30 seconds. I thought it was broken at first but it eventually goes away on its own. While that was going on I also tried to launch a WSL terminal window to see what was happening; that hung too, until the syncthing starter window closed. My guess is that WSL 2 actually has a significant hidden startup time at Windows boot. Normally a WSL window pops up the moment you ask for it, but maybe Windows actually sets up the VM first time in the background and hopes no one notices. Not really sure though, will need to keep an eye on it.

Update: I asked on Reddit and this delay at startup does seem to be a thing that happens to others.

It’s real nice having my source code auto-synced. I sure hope SyncThing never breaks and deletes all my files. (I do have backups.)

Scripting Windows sound and display settings

I have my TV plugged in via HDMI to my Windows machine for occasional gaming. When I want to play games I need to swap the display resolution to one for the TV and also change the sound output device to the HDMI device. I’ve got it set for display mirroring; gaming as a second display sorta works but gets confusing and can require trips back to the mouse and keyboard.

Anyway I got tired of doing it by hand so I scripted it. The key is Nirsoft’s program NirCmd. It gives you a command line interface for doing all sorts of Windows desktop and system manipulations. Here’s the batch file I use to get into desktop mode:

nircmd.exe setdisplay 3440 1440 32
nircmd.exe setdefaultsounddevice Speakers

There’s both a nircmd and a nircmdc. The former pops up a window for error messages, the latter shows them on the console.

Windows and High DPI / Retina

It’s better than it used to be!

I’ve been thinking how nice it’d be to have a higher DPI screen. My current monitor is 109 dpi which is just low enough that I can run things at 100% scaling and it’s all readable. (Sometimes I bump the font size up +1 on things). But I’d love to get a 200 dpi or higher screen so everything looks crisper. This works great on MacOS but historically has been a mess on Windows, in large part because sometimes you are running 20 year old code that is rendering pixels on its own and is totally DPI unaware. But things have improved.

The testing below is with Windows 21H1. I learned a lot from this blog post which explains how to configure Windows high DPI, in particular how to override settings on a per-app basis. I haven’t needed to do that but it’s nice that it’s an option.

I set Windows to 125% scaling and tried a bunch of things. For me my metric of “works OK” is “readable” and “works right” is “readable and not blurry”. Example blurry window to the right. (Note that the app itself works right; only the installer is blurry.)

Most of the apps I use just worked right. A few had to be restarted; they were blurry or in the case of Steam just didn’t work right at all. A few apps were slightly blurry: not “pixel scaled 125% blurry” but more like “awkward font size”, maybe just something not quite optimized. A few older apps worked but were blurry like 125% pixel scaling: Audacity 2.3.3, NZBGet 21.1 (Win UI), SFTP Net Drive. The only thing that was consistently blurry was NSIS, the Nullsoft installer system a lot of software use. There might be a fix package builders can use. Don’t much care anyway, you run an installer once and forget about it. I didn’t test very many games, most games are fully doing their own thing with rendering anyway so I expect they are unaffected by the DPI setting in Windows.

I was honestly surprised at how much did work perfectly. So that impressed me. 125% scaling works almost everywhere in Windows now. None of it feels quite perfect and there are some rough edges but then that’s typical of the Windows UI experience in general. It’s fine and totally usable.

Microsoft has put more thought into display scaling than I reazlied. This helpful developer doc shows the evolution; there was reasonable support starting in Windows 8.1. Windows 10 1703 stabilized on “Per-Monitor V2” with various APIs. The part that surprises me is “Desktop applications must tell Windows if they support DPI scaling”: without that Windows just bitmap-scales and makes for bluriness. I’m surprised almost all the apps I tried are apparently DPI scaling aware. It seems to work even with very old Win32 APIs, you don’t have to use fancy new UWP apps to get scaling. This guide makes it sound not very hard to write basic scaling-aware apps although it does take some extra work to do it nicely.

There is a way to inspect the scaling-awareness of running apps. Oddly a couple of apps (Everything, the PowerToys launcher) say they are “System” status which means basically unaware and yet they look right on my screen. There are a few apps that are fully “Unaware” but they are mostly things like Steam that seem to have their own bizarre rendering for everything.

One thing I can’t tell easily is if the apps are non-blurry because they aren’t scaling at all. I think PingInfoView may be like that; it says it’s “System” scaling but the window was non blurry and the font seemed too small. But the difference from 125% to 100% is not easy to be sure about. I’d care a lot more if I’m running at 200%.

I wish I had a simple program that called the various APIs for inspecting display characteristics and just showed me the info. I guess I could write one.

Higher DPI monitors

Anyway the software mostly seems to work. Now I need the hardware. I currently have a 34″ 3440x1440 monitor that I bought for about $1000. I like it very much. It’s 31 x 13 inches for 109 dpi. There are a bunch of higher density displays but they get pretty pricy.

The Dell UltraSharp 32″ 8K gives you 7680 x 4320 at , the calculator says that’s 275 dpi. $3750 is a little more than I had in mind though.

5K monitors may be more reasonable. Here’s a couple, the first is pretty much a straight DPI upgrade on my existing screens ize.

LG 34″ 163 dpi, 5120x2160, 32″X14″, $1224.
LG 27″ 218 dpi, 5120x2880, 24″x15″, $1600.

Newegg has a lot of choices for 4k gaming monitors, some 16 at 3840x2160 (for a 16x9 aspect ratio).

Looking at this another way... a 43″ 3840x2160 monitor is a pretty common size for $1300 or so. That’s 105dpi, so basically I’d get a bigger monitor at the same dpi. Not interested. To go higher density there’s 32″ 3840x2160. That gives 138 dpi, or about 25% more pixel density. These monitors are 27″x15″ and I’d definitely the loss of width.

What would be a clear DPI upgrade on what I have now is a 5120 x 2160 monitor. That gets me back to that LG 34, I think it’s the closest to a direct dot density upgrade. It’s one of only two monitors in this size; the other is the MSI PS341WU.

The other thing I should consider is pixel depth; 10 bits is common now although I don’t know of any software supports it. And also refresh rate; I like my GSync up to 100Hz. The LG 34″ that looks like a good match for me is 10 bit and supports 75 Hz. No indication of GSync or FreeSync support though. The MSI monitor is 60Hz only.

Just for fun, Apple’s Pro Display XDR is 6016 x 3384 for 218 dpi at $5000 (!). The screen is 28 x 16″. I can’t find anyone selling another brand with this panel.

Bottom line, the LG 34WK95U-W looks like the best option for me and a fairly unique one at that. $1224 on Amazon is not a lot but I don’t think it’s a big enough upgrade to warrant replacing my existing monitor.

TPM 2.0 and Windows 11

Windows 11 news came out today with a big surprise: it’s going to require TPM 2.0 support in your system. What the heck is that? “Trusted Platform Module”, a bit of extra hardware that’s used to store secrets for security and encryption. And a lot of Windows PCs don’t have it. But it can be added.

The easiest way to see if your system will run Windows 11 is to run Microsoft’s health check app. It’ll give you a simple yes/no. If it says “no” it’s likely it’s because your system doesn’t have TPM 2.0. To test for TPM specifically try running “tpm.msc” from the start menu (Win-R): it will tell you the status of TPM on your system.

Neither of my desktop PCs have it, neither my fairly new and fancy Asus X570-Pro nor my older cheaper Asus Z270-P. It seems pretty random whether a desktop machine has it or not. Hopefully most newer laptops do? I don’t know, I think my 2017 Razer Blade does.

You can add TPM hardware to some motherboards. There’s a 14 pin header for that purpose if you’re lucky. My X570-Pro has one, the Z270-P does not. If you have the header can then buy a little motherboard specific add-on module like this Asus one for pretty cheap, $15 or $20. I bet those are about to get scarce!

Some motherboards also support something called “fTPM” or “firmware TPM” (AMD) or PTT (Intel). This implements TPM in other parts of the motherboard’s hardware rather than a specific dedicated TPM. Perhaps that’s less secure, I don’t know. My X570-Pro has that ability. I turned it on in the BIOS and now my system is cleared as ready to run Windows 11. Not sure about the older Z270-P system, the manual has no info on TPM in it.

I’m curious why Microsoft is requiring TPM; given it’s not universal or may only exist behind an obscure BIOS setting this choice has to cut deeply into their market. They use TPM for BitLocker, their hard drive encryption product. I’ve never seen the need to use that myself so never looked in to TPM before. I wonder if TPM is good for anything else in practice? Linux supports it and can use it for some things like generating ssh keys.

Windows 10 sound output devices

Windows’ model of sound output has always confused me but I think I finally figured it out. Particularly how it interacts with apps like Zoom and games like World of Warcraft. Here’s some notes.

Jump down to the section on “Application output device” for the juicy bits on “why isn’t sound playing where I want?”

Output devices

Your Windows system has a set of output devices; placees it can put sound out on. Typically these correspond to hardware devices you own like headphones or speakers, but can also be virtual sound devices for capturing audio, modifying it on passthrough, etc.

The easiest way to see your sound devices is to open the Sound settings. Right click on the volume / speaker icon in your taskbar, or open Settings, click System, then click Sound. You’ll see something like this:

The drop down (“Speakers”, here) lets you choose what your system default output device is. Most apps will play sound to that device. This notion of “default” is the cause of much confusion, read on for more.

Clicking through to “Manage sound devices” gives you a couple of extra options:

There’s a “test” option for each device. Also the ability to disable sound devices. This is useful for annoying devices you never want to use. Like the Acer X34, which is the option to send sound out my video cable to my crappy monitor speakers. Never ever want to do that, so it’s disabled.

Windows has like ten options for setting the sound volume. The most complete one I know is “App volume and device preferences”, you can get there by pressing the Win key and typing “mixer”.

The “Master volume” is the output level for the current selected default output. Each output device has its own remembered master volume that you can change by switching output devices first. Also there’s a per-app mixer available for some but not all apps. I don’t know what populates that list but it’s obviously not very complete.

Application output device

Every app gets to choose which device it sends sound output on. Most apps just send to the system default and you have no control over that. A few specialty apps like Zoom or games with voice chat let you control the output device, typically in the System settings.

Zoom outputs
World of Warcraft sound

Choosing a new sound output can be handy particularly for voice communication systems. Maybe you want most system sound out the speakers but your friend’s voice on zoom in an earpiece. But for most apps “System default” is what you want. But here’s the gotcha:

The system default device can change while the app is running. Most apps will detect that change and switch sound to the new output device. You turn on your Bluetooth headphones and now sound is going out those headphones. Neat! But World of Warcraft is an exception. If “System Default” is selected it will not switch to a new output device even if the system default has changed; it will keep playing to whatever was the default when the game was launched. I suspect other apps do this too. It’s a bug IMHO.

Changing default output device

When you plug in a new device it usually becomes the default output magically for you. Often that’s what you want. But it can become confusing, particularly when you then unplug a device and the default output switches back to something. If you’re not hearing sound, first thing you should check is what Windows thinks your default output device is at the moment. 9 out of 10 it’s that HDMI monitor you plugged in.

I’ll say it again: if an app is playing to the system default and you change the system default, most of the time the app will switch to that new output device. But some apps don’t detect the change. It’s very confusing.

A special note about wired headphones. The headphones I have are implemented as a separate output device. Both my speakers and headphones are plugged into separate motherboard jacks and the Realtek S1220A sound chip implements genuine separate devices for each. Other motherboards do something special with headphones where when you plug them in they electrically intercept the speaker output and divert sound to the headphones. But Windows is 100% unaware of this diversion. My old Realtek ALC887 motherboard did this. If yours does, you will not see a separate headphone device and there’s no way in software to switch between them.

Sound input devices

For the most part, all the notes I wrote about output devices apply to input devices as well. There’s multiple input devices, there’s a default input device, switching between them is a little confusing.

Except: Windows 7 had an idea that there were two default input devices; “default device” and “default communication device”. You can still change the latter if you go to the old Control Panel. In theory that communication device was for voice chat and the other default device was.. your high end microphone for studio recording? No idea. This default communication device concept also applies to output devices. I don’t think many apps ever used the idea much and it seems deprecated in Windows 10.

Also except: some microphone devices have a “Boost” option to make them sound louder. And/or a separate input gain control. I’ve never understood why, it has something to do with line levels or something. Anyway if no matter how loud you talk you’re too quiet, the boost can help you. Only my Realtek headphones have this (not the Microsoft LifeCam), I get there via Settings / System / Sound, then clicking “Device properties” on the microphone, then Additional device properties. That puts me in an old Win7-style app, where the Levels tab has a boost option. I suspect every sound driver is different.

Also also except: you have your choice of sound format that a Realtek microphone puts out. Bitrate, bits per sample, etc. Mine got set to 32 bit output somehow and no other apps worked; the mike was responsive but all you could hear was static. Setting it to 44.1kHz, 16 bit fixed it. I’m not sure what’s required to have 32 bit audio working in Windows, but I sure don’t need it for my voice chat.

Firefox GPU RAM leak

Update: upgrading from Windows 10 version 1903 to 2004 solved this problem. It looked like 2004 solved the problem, and it might have helped, but my computer just barfed again with Firefox holding on to 25GB of VRAM. And with only like 6 tabs open.

Update 4: after several more months I can say Windows 10 2004 didn’t help anything. The really maddening thing is I have two nearly identical systems (same hardware, slightly different software install history). The problem occurs on one and not the other.

I’m chasing down a problem on my Windows system. Every few days it crashes, the GPU acts like its out of memory. I have a fancy 1080 Ti graphics card with 8GB of video RAM and don’t run things long term that use VRAM, so what’s the problem?

Firefox.

First trick was finding out what system processes were using video RAM. Process Explorer won’t show you. But the built-in task manager will. The “Performance” tab gives you a graph of GPU memory usage over time. And the “Details” tab will show you per-process if you add the display columns “Dedicated GPU Memory” and “Shared GPU Memory”.

When first launched Firefox allocates about 100MB of Dedicated GPU RAM. Then as I watched during the day it climbed; 2GB, 4GB... Even closing all tabs but one tab open to about:memory (as simple and passive a page as you could imagine) all that RAM was still open. After 24 hours it was 4GB. After 48 hours it was 17GB. (neat trick, since I only have 8GB of actual video RAM. I guess it pages?) Closing Firefox entirely does release the VRAM.

I’m still not sure what’s wrong with Firefox that it’s doing this. There are reports from users of this problem over the years: this bug is the best match, also this bug and that one. Not much resolution there. I also can’t find any tools to figure out what inside Firefox is holding the VRAM. That about:memory page is only for CPU RAM, not VRAM.

The most likely theory I’ve seen there is that hardware accelerated decoding of HTML5 video is the culprit. That the video decoder is somehow not releasing VRAM. FWIW my system has media.hardware-video-decoding.enabled set to true, the default. I think I can sort of reproduce that as a bug by watching Twitch and then closing it repeatedly. But not Youtube. I think a real culprit might be me browsing meme videos on Reddit using the Imagus extension (which opens media in a popup window). Another possibility is Reddit’s previews of RPAN streaming video. But I’ve not been able to reproduce it consistently in a way I understand.

Another theory I had was that it was related to the webrender experimental feature. But I have gfx.webrender.all set to false, so that’s not it. Also the leak seems to be triggered only by some kinds of pages, not all, and my impression is webrender would affect all pages.

One last bit of cargo cult advice gleaned from the Firefox bug reports is that Windows 1903 fix KB4497935 might improve things. Reading the Microsoft notes for that I don’t see how it’s related. But I am running 1903 without that patch. I think that’s the next thing I’ll try; install that patch and see if the problem goes away. (Also why am I not running a newer version of Windows?!)

Update: joke’s on me, I can’t install KB4497935 standalone. Installer refuses to run and says it’s not for my system. Maybe it was superseded by a later patch? In general I keep my systems updated, that seems likely. Anyway I’m going to just jump to Windows 10 version 2004 now, that’ll definitely mix everything up.

Update 2: I ran for a couple of days on 2004 and it definitely fixes the problem. At least, mostly. Firefox regularly returns big chunks if video RAM as soon as I close a tab. More importantly I kept it running for two full days and at the end it had maybe 500MB allocated. A bit more than the 100MB or so it started with, but well below the 8+GB that resulted in system crashes before. I don’t know what in particular fixed it, but something in the transition from Windows 10 1903 to 2004 either fixed or papered over the problem.

Update 3: I swear 2004 has helped. But just now I was playing World of Warcraft (uses 2GB of VRAM) with Firefox in the background with about 8 tabs. And WoW complained it had no RAM and when I checked, Firefox had 25GB of VRAM allocated to it. Quitting Firefox fixed it.

Computers are complicated.

WSL access to Linux files via Plan 9

Microsoft shipped Plan 9 filesystems! Starting with Windows v1903, the Windows Subsystem for Linux now includes the ability to access your Linux files. To a casual user it’s very simple; you just open paths like \\wsl$\Ubuntu-18.04\home\nelson\.bashrc in explorer.exe or VS.Code or whatever and it all just works. Quite well too, I’m impressed. So far the only hiccup I’ve noticed is it doesn’t support symlinks, not even ones internal to the Linux filesystem.

Behind the scenes there’s a Plan 9 network filesystem involved. That’s not as weird as it sounds, I wrote some notes on it awhile back. Now Microsoft has released a technical overview video. Here’s some highlights:

  • Plan 9’s filesystem is a very simple network filesystem protocol to share files between systems. They are specifically using 9P2000.L.
  • They considered using Samba and SMB instead but can’t rely on Samba being installed and usable in the Linux guest OS and didn’t want to ship it because Samba is GPL licensed.
  • They picked Plan 9 because it’s much simpler to implement. Also Microsoft already had Plan 9 server code for some other Linux container project they’d done.
  • The \\wsl$\ path is handled in the Windows system by the MUP, an existing hook for network-like filesystems. They added a new one for Plan 9.
  • The $ is in the name so that it can’t be confused with a computer whose hostname is wsl.
  • The Plan 9 server in Linux communicates with the Windows Plan 9 client via a Unix socket. (Windows supports Unix sockets; who knew?)
  • Windows can access your Linux files even if no Linux is instance is running. There’s a new Windows service called LXSManagerUser that mediates user identity and permissions.

I continue to be impressed with the quality of WSL; it’s like a real Linux system in almost every way that matters. Microsoft has big plans for a second implementation now called WSL2 that will run a full lightweight VM. I’m not as excited about that but they say it will help improve filesystem performance, something that WSL definitely could use.

Installing esridump on Windows

I just wrote these notes up for a friend. esridump is a Python tool that will take the URL from an ESRI ArcGIS REST server and dump all the data in it to a GeoJSON file. It works by doing REST queries on the predicate “where 1=1;”, the only subtle thing is you have to paginate the requests because there’s a limit to the number of results from one query. It’s a nice tool; there are several others floating around out there like it.

Installing it is basically as simple as “pip install esridump”. It has very few dependencies, no GDAL or other GIS giant libraries. But I wrote these detailed notes for a friend of mine:

ArcGIS RES

  1. Install Python 3.7.3. Make sure to click “Add Python 3.7 to PATH” when installing.
  2. open a cmd shell, everything else is in there
  3. cd Documents
  4. mkdir pyesri
  5. cd pyesri
  6. python -m venv venv
  7. venv\Scripts\activate.bat
  8. pip install esridump
  9. venv\scripts\esri2geojson.exe http://SERVER-URL/ out.json

Plan 9 rides again; WSL file access

There’s a handy new feature planned for WSL in Windows 10 v1903: “Accessing Linux files from Windows”. Previously there was no way to get to your WSL Linux files from Windows, the host Windows OS didn’t know how to interact safely with the LXFS files in the WSL system. Now you’ll be able to mount the Linux files as a network share.

The cool part is how it works: “a 9P protocol file server facilitates file related requests, with Windows acting as the client”. Before they edited the announcement they called this “a Plan 9 file server”, which is accurate if a bit overstated. 9P (aka Styx) is a Plan 9 network filesystem technology.

It makes sense to use a network filesystem to bridge Windows and Linux. I’ve been doing something similar, network-mounting the Linux files via SFTP. You could also imagine running a Samba server inside WSL that the host Windows system accesses. Either way the Linux process gets to mediate the file access, at the expense of a network file system.

Plan 9 is the wacky part. There’s been a little discussion about why, hopefully Microsoft will write a blog post explaining the tech. My guess is they chose 9P because it is very simple to implement. IIRC part of the Plan 9 design is that many applications implement a filesystem as their API, so they built a simple embeddable filesystem any program could control. Wikipedia’s summary of the protocol certainly looks straightforward, roughly what a FUSE filesystem implementation has to implement. Still, a tiny bit surprised they didn’t go with their own SMB, or NFS, or something new and proprietary and super simple.

There’s obscure precedent for using Plan 9 this way, see this discussion. QEMU’s VirtFS uses 9P to share files between guest and host operating systems. (Which led to at least one security issue in a QEMU user.) And there’s some 9P code knocking around: the old u9fs code presumably hasn’t entirely rotted, there’s v9fs (looks abandoned?), someone took a crack at 9P in GoLang, and there’s probably useful 9P code in this Plan 9 port. Also Wikipedia mentions Styx on a Brick which looks like a way to control a Lego Mindstorms robot via something that looks like a filesystem.

Update: Chromium OS also contains a 9p server, I think also used to bridge over VM boundaries.

Edit WSL Linux files from Windows with SFTP

I just hit on a way to edit files in WSL that in retrospect seems really obvious. I’m wondering if there’s some reason it’s a bad idea. It seems to work!

The problem I’m trying to solve is editing files in the Linux partition of WSL from Windows. Ie: editing $HOME/.bashrc with Notepad. We’re told to absolutely never change the Linux filesystem files from Windows because things can break.

So my solution is to run the sshd daemon under WSL. Then use that to connect to my Linux files via SFTP running as a Windows app. I’m using SFTP Net Drive to mount my Linux files as a Windows drive, there are other options. Then use any Windows program to edit the files in that drive, like Notepad or Sublime Text.

All the actual file I/O is happening under WSL thanks to SFTP, so it should be safe. SFTP imposes some overhead but it’s not a big deal for just editing files. One nice thing is SFTP seems to do a pretty good job at preserving Unix file permissions even when editing from Windows.

Update: I’m now doing this regularly, all the time, with the Linux partition mounted as W: in Windows. It’s great! Makes a big difference having easy access to the files over there.

Update 2: this trick works but is no longer necessary. WSL in Windows v1903 includes support for accessing your WSL files via Windows paths like \\wsl$\Ubuntu-18.04\home\nelson. Underneath the scenes it’s using a Plan 9 network filesystem to bridge things.

(originally posted to Reddit)

NTFS filesystem corruption in practice

I unplugged a USB drive without unmounting it first and got burned for my troubles. Windows was able to repair the disc and I think recover all my files, but I had to do it manually.

I use a hard drive to sync files between two Windows desktops with FreeFileSync. I now just unplug the drive whenever I want it; Windows can’t unmount it properly, always says it’s in use, maybe by the backup subsystem? Anyway, I just pull the plug.

So I went to sync the files from the drive to the other disc and it acted wonky. A few files disappeared during the sync. Some other files I expected to exist didn’t. Windows prompted me to run a check or repair via a notification but clicking that did nothing. Manually right clicking the disc and doing Tools / Check and Repair did work though. And afterwards the files I was expecting to find came back. At least I think so, I don’t have a complete audit.

I’m confused how Windows NT is willing to mount a USB drive that wasn’t unmounted cleanly without immediately recommending a check & repair. Also a bit confused about the pattern of what files went missing; it wasn’t just the newest stuff.

 

Windows 10 fail, safe mode, reboot

My Windows 10 box failed, hard. Well maybe soft, who knows? It would boot and log me in as a user, then the system graphical shell would hang, little spinny cursor. One window is visible on screen, Razer Central. That’s some nonsense to turn off the stupid light on my fancy gaming mouse and is notoriously bad software, so maybe it caused the whole system to hang? But even after killing it (Task Manager worked) the system was still hung. FileExplorer seemed to be spinning at 100% of a single CPU core, that’s not a good sign.

Anyway it took me a couple of hours to get the system back. Booting into Safe Mode or accessing other recovery tools on Windows 10 is not at all clear; these docs finally helped me. I tried restoring to a System Restore Point first and that didn’t help, the system was just as broken as before. Fortunately I’d made a full system backup yesterday (using the old Windows 7esque deprecated tool) and restoring that fixed it.

Not sure what really was wrong. The computer had been off for about two weeks, then failed after it rebooted itself to apply some Windows 10 system updates. There were also some Razer updates to install and given that it was on screen when the rest of the system was broken and their reputation for broken software, I’m inclined to blame it. This isn’t even the Razer laptop, this is just a normal Windows machine that had a Razer mouse and I’d installed the software to, like I said, turn off the stupid light on the mouse. Anyway now I’ve excised that software, turned off a lot of other third party services that want to launch at boot (screw you Adobe updater), and will reboot with my fingers crossed.

Update: a few days later I finally worked up the courage to try rebooting. And it worked. I’m 90% sure that the Razer update had some interactive thing it had to do that failed and blocked the rest of the upgrade boot.

Windows newlines vs Unix bash

I was having the weirdest problem debugging a shell script. “bash -x” was showing stuff like this:

++ mktemp
+ T=$'/tmp/tmp.FJZp7VfwsA\r'
+ ogr2ogr -f geojson $'/tmp/tmp.FJZp7VfwsA\r' $'../hhl15/hhl15.shp\r'

I was using mktemp to create a file. Why was bash showing it as $’filename\r’?

Turns out, derp, SublimeText on my Windows box create the file. With Windows newlines by default. Which bash will treat as important whitespace and not strip. So if you ever see a $’\r’ in your bash -x output, that’s your damage.

 

Windows: typing European on American keyboard

Apple has this great way to type non-ASCII characters like Ö or ß or € on both MacOS and iOS. You long-press the key that looks similar to what you want (an O, or an S, or a $) and then wait a bit and a UI pops up and you choose what you want from a UI picker. It’s not great for fast touch typing but for that you’d want a full language keyboard. But for wanting to type the occasional non-English word, it’s great.

Windows, not so much. The frequent advice is type it by character code as if I’m going to memorize 153 and 128 and 223. Not to mention my laptop doesn’t have a numeric keypad. The advice to use the Character Map in that post is not so awful, it works OK, but it’s pretty clumsy.

The best bet seems to be the US international keyboard. It’s an alternate American keyboard where ’ ” ` ~ ^ are dead keys; they’ll modify the next letter to be accented, or else insert themselves if that makes no sense. It works pretty well. Even better the right Alt key can be used to type a bunch of other stuff like ß or €. It’s not perfect but it’s pretty good. Note the Windows 10 anniversary edition moved this; it’s now listed as an “Option” on the English (US) keyboard, not a separate keyboard.

I also tried Holdkey which promises to add an Apple-like typing UI. But it didn’t work very well, the way it grabs onto the keyboard is problematic. There’s some other options along these lines I didn’t try.

Update: if I type y’all I get yáll which I think is hilarious.

Update 2: by default Ctrl-Shift switches between keyboard layouts. That’s obnoxiously easy to press by accident. You can turn that off or change the key mapping.

Alfred replacements for Windows

I loved Alfred on MacOS. 95% of the time I used it to launch apps with the keyboard, but I also liked its clipboard management, access to Google searches, etc. What about Windows? Turns out there’s lots of options. I cribbed these from this Reddit discussion, also see this article. Many of these are cross-platform and work on Mac and/or Linux.

Hain is pretty slick and what I just chose to switch to. It feels almost exactly like Alfred to me, the only thing it’s missing is number key shortcuts to pick items. It’s not very configurable (no skins for instance) but the defaults are good. I added some plugins: Clipboard (to replace Ditto), Google. The terrible / great thing about Hain is it’s implemented in Electron so there’s a full HTML5 shell running. Or several maybe. I see four hain.exe processes total about 200 MB of RAM. And 0.02% CPU which is small but not zero.

Zazu is newish and open source. It seems OK but not as polished as Hain; configuring it requires editing a JSON file, for instance. It’s also HTML5 based (Chrome?), 240MB in memory and 0.02% CPU.

Wox is popular and pretty solid. The install is strange; it says it requires you also install both everything (a file indexer) and Python3. But I think those are both optional upgrades. It’s a little ugly out of the box, Hain is nicer. Wox is 125 MB of RAM and 0.12% of CPU. It’s built in .NET.

Launchy is what I used to use. It’s old and ugly and doesn’t really do anything but launch apps. And that, not very well. Nothing to love but it does work and is free.

FARR is another option with a long history. I couldn’t figure out how to rebind the hotkey, and it’s kinda old and ugly too, but it seems very capable. Also quite small; 20 MB RAM and 0.00% CPU when idle, like it should be.

 

While I’m here, a shout-out to Seer which gives a space bar quick-preview to the Windows Explorer, like MacOS finder has. It’s about $12. Lightshot also seems like a nice improved screenshot-taker. It’s free, I think they’re trying to drive ad traffic to prntscr.com. (Speaking of which my Apple keyboard has no PrntScrn button. It does have an F13 though which you can bind in Lightshot, even if the UI shows a blank key when you bind it.)

Windows sshfs clients

I want to access a remote machine’s Unix filesystem via ssh, the way you’d do with sshfs and FUSE in Unix. There’s a lot of options for it.

  • SFTPNetDrive, what I’m using now. Works simply out of the box. Free for personal use, $100 for commercial use.
    Seems fine, Y: is now my remote disk. Has some reasonable customization options but nothing overwhelming. There’s an option to mount the disk as “Network, Removable, or Fixed”. I was hoping that could fake out WSL so that I could see the remote disk in the Ubuntu-on-Windows subsystem (which now supports removable disks). No such luck.
  • NetDrive, the big daddy commercial system. This provides interfaces for a whole bunch of cloud storage options: S3, OneDrive, etc. 30 day eval, then you pay $50
  • ExpanDrive, another multi-service commercial option. $50
  • sshfs-win using WinFSP. Open source FUSE-like solution. Looks promising.
  • win-sshfs, a fork of an older project (keyword: Dokan). No commits for 9 months, but does have Windows 10 support so it’s not totally dead.

 

Canon MX850 and Windows 10

tl;dr: reinstall the Windows 8.1 driver to get the scanner working.

I have a Canon MX850 I bought 8 years ago. It’s one of those cheap multifunction inkjet printer/scanner/fax things, the ones that cost $20 but each ink refill costs a small part of your immortal soul. The printer has been pretty reliable, but the scanner keeps failing. I’m not certain but my guess is that Canon’s network scanner driver isn’t smart enough to follow the scanner through IP address changes from DHCP. But the printer keeps working, huh.

Anyway, the simple fix is to download and reinstall Canon’s driver. No need to uninstall first. Windows 10 is not supported by Canon, but the 8.1 (x64) driver seems to work fine. At least scanning does, via Windows Fax and Scan. Haven’t tried the fax side.

Synchronizing Windows directories

I’ve been using Allway Sync to keep my two new Windows machines in sync. It’s pretty good. I sync one machine to an external hard drive, then sync that drive to the other machine. So really it’s three copies. Allway Sync also supports various Internet services for syncing, like Dropbox or its own cloud service.

The sync algorithm seems relatively robust. It’s a bidirectional sync, so changes on both sides can propagate at the same time. There are safety features like a sanity check if too many files changed. It tracks metadata and deleted files so deletes can propagate. It also keeps old versions of things in a hidden _SYNCAPP folder. I haven’t delved into details of how it handles a single large binary file that’s only partially changed, I don’t know if it has binary diffs or if it just copies the whole file over.

The UI is pretty awkward. Mostly it’s just ugly. But it’s also a bit confusing. I believe you have to define a new job for each folder you want to sync. (There is a way to sync one source folder to multiple destinations.) I finally found that if you enable the toolbar, there’s an icon for “sync all jobs at once”. I haven’t tried the automatic syncing yet, it seems to rely on a service watching for change file events and/or on a timer.

The trick now is figuring out what all in Windows I can safely sync. My Steam apps folder is safe to sync, and saves me from having to download a 30GB game twice. Syncing my Documents folder seems to work too and propagates some app settings, game save files, not to mention my actual work output like source code and text documents.

The part I’m on the fence about is syncing my Roaming profile. That should keep many more app settings in sync, and my first time copying it seems to have worked OK. But there’s a lot of random stuff in there that doesn’t quite seem like it should be copied, like Slack’s cache files. OTOH the Roaming profile was designed to be copied from one machine to another, so it should work? Edit after trying it I think syncing the whole Roaming profile is a bad idea. Parts of the folder, like Microsoft, seem to be treated specially. Also it makes the most sense to sync when nothing is open that writes to that directory, ie before you log in, and that’s awkward.

It’s free, but there’s a limitation on the number of files. The license is $26 but that’s for a single machine. $16 for a second one.

There’s a bunch of other sync options too. For a long time I used Unison to sync file systems. It works great and I’d still use it for a Unix command line. There are Windows build but I couldn’t get the GUI version to work. I also get nervous using Unix tools to manipulate Windows filesystems.

 

Windows: backing up a failing disk

Ken’s Windows 7 machine has a hard drive failing. Some errors, a few corrupted / lost files. We’ve already bought a replacement drive but are having a seriously hard time getting useful data off the old disk. The disk mostly works; he runs it with Windows for hours at a time (I know, bad idea). But it has some bad sectors.

Simple task: just make a backup. Copy all the files off of it. Windows Backup doesn’t seem to work with no useful feedback why. Casper, a third party disk imaging tool, gives up the moment it encounters a read error. Acronis True Image, another cloner, is free for Western Digital drive owners but the installer doesn’t even run. PCmover isn’t really a backup tool and isn’t backing up complete data. It’s a fucking clown show. I’m about to bust out a Linux system just to run ddrescue. I did find a suggestion that HDD Raw Copy Tool might work.

Hard task: set up the new PC. Ken would very reasonably like to migrate his own data and settings from Windows 7 to a new Windows 10 install on a new disk. This proves to be very difficult from a working disk and nearly impossible from a failing machine. Windows 10 abandoned Easy Transfer. Microsoft did a deal with PCmover but the software is a joke, most of what it moved doesn’t work on the new system. A specific problem is his username changed on the new Windows system and everything seems to have hardcoded the pathname of his old username, not just %user%.

Windows is such garbage.

 

Windows metered network connections

My ISP is down again so I’m back to Verizon tethering. Setting up the network connection I noticed Windows has a metered network option. The docs are very vague, but basically it’s a flag to tell the OS and applications “hey, this network isn’t free”. Windows itself will be a bit more careful; only downloading priority updates for example. There’s also configurable options to not sync OneDrive or download device drivers.

In theory third party apps could also inspect this setting and be smarter on a metered connection. Specifically apps on the new “Universal” platform. In practice I wonder if many apps are that smart. Dropbox isn’t, apparently. It’s all a bit confusing really, and most of the search results you see on Google about metering are “why isn’t stuff updating how do I turn off this metered connection thing?”

Also TIL that Windows 10 enrolls your computer as a peer to peer server in uploading Windows updates to other Windows computers. Yes, by default Microsoft assumes you want to use your upstream bandwidth to serve other customers. That’s some fucking bullshit.

 

Ah, Windows, ye olde errors

Bloom is off the rose with Windows. Or at least, Civilization 6, one of the games I switched to Windows to be able to play well. (It runs on Mac but 50% slower, and I wanted higher end graphics hardware.)

The whole system often freezes when exiting the game to desktop. Well that’s not quite right, Ctrl-Alt-Del still works and you can reboot or log out. But Alt-Tab doesn’t work to switch apps, which is odd because it works fine while the game is running.

GSync also doesn’t work. That’s the fancy variable framerate stuff. All sorts of screen tearing unless I enable VSync.

Both of these bugs could be specific to Civ 6. But it’s the kind of thing you’d think the OS and its graphics drivers would take care of uniformly for all games. Ha, as if.

 

Windows S.M.A.R.T.

Windows doesn’t seem to have built in S.M.A.R.T. support! After reading this guide and this Stack question I think the best option is CrystalDiskInfo. It used to have some bundled adware but the author promises he removed it all, and there’s a portable version for download (ie: no installer). I took a chance and it seems to work.

Capture.PNG

That’s my USB drive. Ignore all the junk and focus on “Health Status: Good”. Its heuristics seem reasonable; at least it shows my two new drives healthy and identifies errors in a failing drive that look plausible.

Gripe

Why the fuck doesn’t Windows have basic SMART error monitoring and notification? It’s the first line of detection for a failing drive, popping up errors for the user would save countless amounts of lost data. (And ignore the advice to try Windows’ wmic; at least on the drive I know is failing, it shows “OK” even though it’s not.)

And why are SMART tools so bad? Note the same user-hostile display table at the bottom as every other SMART tool in the world shows. What’s the temperature? 123? 111? No, it’s 00000000001D, which for some reason is being displayed in hex with leading zeros. At least this program translates it to 29C. No idea what the spin up time might mean though. I don’t even know what “Current” and “Worst” are supposed to mean. Linux smartmontools shows the same nonsense.

Speaking of smartmontools, I tried installing like four versions of it for Windows from dodgy SourceForge binaries. They all sucked, many couldn’t even find my drives. So much terrible Windows software out there.

Ken’s computer is showing signs of a failing hard drive. Last CHKDSK randomly found about 30 files corrupted. The machine is about five years old, just in time for a shitty consumer hard drive to fail. Ugh.

 

An example ugly Windows font

I’ve complained about Windows font rendering but was hard pressed to have a good example. Well here’s one, from a Bloomberg articleCapture.PNG

Look at how ugly that is! The kerning in “To” is wrong. The “m” and “r” and “u” and “n” are all broken, by which I mean literally broken like white pixels in the middle of the letter. The tail on the “9” has visible jaggies. I’m not just nitpicking, I find this really difficult to read.

The font is a web font, TiemposTextWeb, at 18px. Maybe it’s just a spectacularly bad choice? But Bloomberg is a big publication, clearly someone thought it was a good font. That sample is rendered in Chrome; it looks the same in Edge. I have ClearType turned on with more or less default settings in Windows 10; I used the tuner to pick a very slightly heavier rendering at some point but I don’t think that’s the problem.

It looks much better in the PDF specimen. Here’s some sloppily-made images of the PDF and then Chrome / webfont rendering the same text, to show the spindly nature of Windows’ rendering.

pdf.png

ttf.png

Another example

Another example, Gentium Basic, an SIL font popular because it has support for a lot of scripts. The lowercase “a” is entirely broken, even at 30px.

Capture.PNG

I mean that’s some fucking garbage right there. It looks a bit better if install a TTF and render it with Paint.  It still looks bad, but at least it’s not broken, just ugly-ass.

Capture.PNG

On the same page there’s a “Gentium Plus” that looks a little better still. It’s not great, but it’s at least not embarassing. So maybe font quality is part of the story, but something very bad is also happening in Windows’ font rendering.

Windows customizations

I’ve now set up a second Windows box. I was in a hurry and didn’t take notes, but from memory here are some of the specific tweaks I made in addition to installing normal application software.

I sure wish Windows had a clean way to store these customizations and copy them to a new machine. MacOS is much better; almost everything is localized to your home directory and Time Machine will help you set up a new Mac.

I thought I’d be clever and copy my roaming profile over to the new computer. That worked for some things like Discord and Slack. But lots of configurations are stored in other places. Cmder still stores its config files right in the program directory for instance, which seems like a good idea if you’re using it as a portable app but otherwise is not a good thing. And some applications settings are buried in the registry and I don’t know of an easy way to extract the ones you can safely copy over.

Windows 10: separate speaker and headphones

I have both headphones and speakers plugged into my motherboard’s analog output jacks. It’s a pretty standard Windows desktop setup, the motherboard does HD Audio which has 5 analog jacks which can be programmed to do different things like speakers, headphones, line-in.

Also pretty standard, my computer had the RealTek HD Audio Manager installed, an ASUS skinned one. This does a nice job of popping up a dialog when the user plugs in new speakers and asking them to configure it. Unfortunately it also seems to have a behavior where when I plug in headphones it automatically silences the speakers. In fact both analog outputs show up as a single “Speaker” device in Windows, there’s no way to use them independently.

In theory the Realtek driver has option settings to reconfigure this behavior, to let you use the rear and front jacks as separate devices. But my version didn’t have those settings, no “Playback Device” section at all.

Following some cargo cult advice I solved this problem by just uninstalling Realtek entirely. Goodbye 500 MB of stupid reverb effects I’ll never use. Turns out Windows 10 itself can manage the audio hardware with no problems. I did have to unplug and re-plug the devices for Windows to detect them, but now my speakers and headphones show up as separate sound devices.

Capture.PNG

While I’m here, a little theory on how this all works in Windows. Each sound device is an independent output channel for apps to play to. Most apps just play to the “Default App”, which you configure in the Sound control panel or with a program like SoundSwitch. But some apps let you choose a specific output device, particularly games, and you can use that to play different sounds simultaneously through different apps. There’s also a notion of a “Communications device” separate from the usual default, I think for VOIP apps like Skype to use a headset always.

I’m still confused about what drivers are involved. Device Manager tells me stuff is being managed by Microsoft’s Driver 10.0.14393.0, which I think is just Windows 10. But Sound tells me that there’s also a RealTek Controller which a RealTek Driver 6.0.1.7910. I wonder if Microsoft ships that, or if I didn’t uninstall that driver when I uninstalled the Realtek Audio Manager?

Update: this stopped working after I rebooted.

Update 2: a reader wrote to suggest

The problem is that Windows 10 reinstalls the Realtek driver automatically (in the background without asking no less...). To stop that you can open the device manager and open the “Sound, video and game controllers” list (not “Audio inputs and outputs”, there it doesn’t work). There you will see that your audio device is a Realtek device again. Open properties, go to the driver tab and click on “Roll Back Driver...”. Now you will get the Windows driver and it wont reinstall the Realtek driver.

ConEmu + ubuntu on windows: bell

I’m pretty happy with how my Unix setup on Windows is working. But there’s one horrible thing; the awful bell sound in the terminal emulator. Every time I hit tab in bash to complete it plays a good old ASCII 0x7 BEL, and it’s some earth-farty three tone loud sound that is just awful.

The solution is simple; go to the volume mixer and set the volume for “Console Window Host” to 0. Now your shells won’t make any audible noise. Of any kind. Peace and quiet.

What I really wanted was to reconfigure the bell sound. PuTTY has a whole set of options for this. I think it’s not really possible though. ConEmu can’t or won’t do it, as the author angrily keeps telling users. Apparently his code isn’t playing the bell at all, it’s being passed through to a lower level Windows console handler of some sort. There is an option for intercepting the bell but it’s not working for me for some reason, at least not on Ubuntu-on-Windows. It does seem to work for msys.

Another option often suggested is to configure your Unix programs not to use a bell for alerts. You can set it in bash, and GNU readline, and vim, and less, and... that way lies madness.

It turns out the sound is actually being played by Microsoft’s software, somewhere deep in their version of Bash or WSL or something. And it’s apparently not configurable. But you can find it in the volume mixer and cut off its air supply.

God that sound was awful.

Keeping time, time, time,
In a sort of Runic rhyme,
To the tintinnabulation that so musically wells
From the bells, bells, bells, bells,
Bells, bells, bells --
From the jingling and the tinkling of the bells.

Update: the plot thickens. The sound that’s being played is supposed to be a honest-to-good beep, the one generated by the motherboard with its integrated trashy speaker. Not your fancy stereo sound system. Modern hardware doesn’t have speakers, and starting in Windows 7 there was a special “beep driver” written to intercept this low level beep system ability and replace it by playing a wav file.

The sound Windows 10 seems to be playing is the sound event “Critical Stop” which is set to play “Windows Foreground.wav”, that horrible sound. I replaced it with “Windows Ding” and it’s better.

Unix environments for Windows

One thing I miss about my Mac is having a usable Unix environment. Now I have two on my Windows machine, with different significant flaws. MacOS isn’t a great Unix, but it’s perfectly adequate for basic stuff. And it’s really handy having tools like rsync and command line ssh around. Windows has its own command line world with the venerable CMD.EXE (DOS) and the newer PowerShell. But screw that, I want Unix. Here are options.

Ubuntu-on-Windows (WSL)

This is the new hotness from Microsoft and is very nice. It feels like a legitimate Ubuntu environment. Except so far it doesn’t support networked filesystems.

WSL sits as its own OS on top of the NT kernel, just like Windows is an OS on the NT kernel. There’s not a proper Linux kernel running, instead Microsoft has emulated the Linux kernel at the syscall interface. The userspace then runs stock Ubuntu, actual Ubuntu x64 binaries unmodified. It’s an impressive piece of work.

The drawback is not everything works. ping doesn’t work unless you run bash as Administrator. (Some docs I’ve read say ICMP isn’t implemented at all.) Filesystems are limited. USB drives don’t work. Network file shares don’t work. There’s no NFS support in the Linux image, nor is there FUSE support. The view of the underlying Windows filesystem (in /mnt/c) is a bit strange too, like I can’t see a proper view of my Desktop folder. In general stuff that works seems to work right, and the Microsoft team is moving fast in adding new features. I’m tempted to join Windows Insider just to start running betas, but I think I have to get a whole new Windows version, not just an upgrade to WSL.

There is an honest /sbin/init process running in WSL, PID 1, but its only child by default is the bash shell you start the thing with. So no init scripts / systemd running services. You can open multiple bash processes that can all see each other and share a filesystem. But if you close the last bash, you lose the whole WSL environment, which makes daemons a bit awkward.

Other names for this system are Windows Subsystem for Linux (aka WSL) and “Bash on Ubuntu on Windows”. Note these make for awkward search terms on Google.

Cygwin

The granddaddy of Unix emulation for Windows. I haven’t tried it in a few years, but I used to hate its package manager and its approach to Windows integration. Weird path names and environment. But it works pretty well and has a significant set of tools. MobaXterm bundles Cygwin in with an X server and terminal emulator.

msys2

The other venerable Unix option for Windows, some evolution of msys / msys2 / MinGW / mgwin32 / MinGW-w64. It has some Cygwin roots in it too, I’m not sure how much, but the mingw philosophy is to make things more like Windows and less like Unix. The result is a lighter weight Unix environment with some compromises. For instance symlinks aren’t supported because they wouldn’t work in Win32 apps. So instead creating a symlink makes a copy of the file, which is pretty damn broken but you can live with it. The crazy neat thing is the Unix programs like make are actually Windows executables like MAKE.EXE and will work fine in Windows, without bootstrapping a Unix environment. Handy for ssh.

There’s no visible init process, you just have a naked bash running according to ps, although its PPID shows as 1. Software is managed via pacman (as used in Arch Linux), there’s a large variety of packages and a toolchain for building your own. I’m not wild about the package and software versions and a bunch of basic stuff isn’t installed by default (like tar). Also some of the tools have idiosyncracies. And I have some problems like Ctrl-C not interrupting IO bound bash scripts. But it’s definitely a usable Linux environment, just not Ubuntu.

Git for Windows (aka msysGit)

This shows up as a recommended Unix option. It’s a tight, easy to install bash shell plus enough related utilities to run git. It is based on msys2, some of the history is here. It does not include much though, like there’s no rsync. And no compiler toolchain, no package manager for installing more stuff. It’s great for providing a git command line though.

Terminal window

Unix programs really want to be running in an xterm/vt100 emulator. There’s a bunch out there. I’m liking Cmder, which is an enhancement wrapper for ConEmu. mintty is another option, that’s what msys2 uses by default. wsltty is a customization of mintty for WSL. MobaXterm is also popular. Note that PuTTY/SecureCRT is not really needed any more. They are a combination of terminal emulator + ssh, but now you can just use a simple emulator plus OpenSSH command line. Still working on a good ssh-agent solution though.

History

As a historical footnote, WSL is not the first unmodified Ubuntu to run on Windows. There’s also andLinux, based on coLinux, a cooperative VM. There’s some other Unix-alike Windows options out there too, I think mostly abandoned. See also Interix and Windows Services for UNIX.

Windows 10 gripes

I’m now a week into switching from Mac to Windows and have mostly settled in. Here’s a list of gripes I have about the Windows experience. Compare to a similar post I wrote in 2011 when I switched to the Mac. Honestly mostly the Windows machine is fine and I think this change will take permanently. But you notice things when you try something new.

Operating system problems

Windows is actually not a bad operating system, the NT kernel is pretty good. But there’s still a lot of warts.

File paths are still broken in Windows. Stuff installs and writes files all over the filesystem: Program Files (two versions), root directory, various user directories. The fact that I need to know about a pathname like C:\Users\Nelson\AppData\Roaming\Sublime Text 2\Settings is terrible.

I have two GPUs: the motherboard and a fancy gaming card. It’s really unclear to me which GPU is used when. In theory I can use the motherboard plug but it still uses the card? I couldn’t make that work reliably, so I just used a plug on the card.

There’s no way to make Windows re-open programs you had open when you reboot and log in. And if you want a program to start when you log in, it’s a hideous process of opening one of two magic folders and creating and dragging shortcuts. Seriously, I have to make a shortcut and put it in C:\Users\Nelson\AppData\Roaming\Microsoft\Windows\Start Menu\Programs. That’s handy.

Legacy problems

It’s remarkable how 30 year old DOS software still works on Windows 10. But that legacy support comes at an increasing cost.

There’s an uncomfortable mix of Windows 7 and Windows 8 philosophy in Windows 10. For instance there’s two overlapping sets of system settings: Control Panel (Windows 7) vs Settings (Windows 10). Also there’s too many backup options. The Windows 10 things are better, but they aren’t complete so you need the legacy Windows 7 sometimes too.

Windows still comes in a 32 bit version! That’s nuts. Worse, applications are also distributed in both 32 bit and 64 bit builds. OMG why? I wonder how many users choose the right one? And they’re installed in separate folders. “Program Files (x86)” is a very awkward name for a folder. There’s uglier stuff hiding under the covers too, like file system redirection.

Windows 10 still expects DOS newlines in files. Files have both CR+LF to end a line, and tools like Notepad won’t display a file correctly if it only has LF like everyone else in the world. This continues to cause headaches when using Windows tools to edit Unix files.

UI problems

Windows 10 is ugly. MacOS is so calm and harmonious.

The biggest problem is the UI still seems designed for 75ppi screens. Modern LCDs are 100+ppi, so everything is too small. System tray icons are 16x16! A lot of apps default to 8 or 9 (points? pixels?). I get a headache from squinting and leaning close.

Microsoft has created display options to scale everything; 125% does look more or less the right size. But apparently every single app has to be smart about scalings; if they don’t, it goes blurry like it was up-sampled with a bicubic filter. Many apps are OK. But Electron apps like Slack and Discord have this problem right now, apparently a fix is on its way. Also Chrome up-scales all the images in a web page to 125% as well, which is entirely unacceptable and makes the scaling setting useless.

The fonts are ugly. They look spindly, thin. I’ve tried tweaking ClearType to make things better with not much success. Font rendering for CJK fonts is so bad a bunch of users have created alternate font renderers like MacType. But their installation is spooky and the English documentation is not great so I’m not using them.

So many apps play sound notifications. For instance, social apps like Adium and Discord love to make noise when people join/leave. You can turn these off in each app. But it’s hard to find which app is making noise. The Volume Mixer program will show you but the window is small and modal and not really practical to leave running all the time.

The default sound set in Windows 10 is goofy, too light and ethereal. I’m particularly missing a way to have a good clean beep sound for the BEL character in ttys.

The mouse scrolls backwards! This is actually Apple’s fault; they were the ones to reverse things in the first place. But now I’m used to it and switching back is annoying. There’s hacks to reverse it in Windows, but I’m soldiering on.

Mouse scrolling doesn’t feel good on Windows. The “scroll 3 lines at a time” hack in the driver seems dumb. And sometimes the wheel scrolls backwards at the end of a gesture, either through hardware flakiness or my fingers being inaccurate. Either way I never noticed a problem on a Mac.

It’s awkward that Windows uses Ctrl-C for copy and Unix uses it for terminate process. In general I prefer the Mac’s use of the Cmd key and wish Windows used Alt the same way. And don’t get me started on Windows’ apps love of Ctrl-Shift-Win-X type hotkeys.

Missing features

Here are some things from my Mac I miss on Windows.

I miss auto-correct for typos. I’m confused because this is built in to Windows 10, and does work for me in MSIE Edge. But it doesn’t work in Notepad, or in Chrome, or many other apps. Apparently Chrome does its own thing. Also autocorrect only works for UWP apps, ie new things. Notepad seems like a strange oversight.

I miss the MacOS/iOS way of entering “special characters”. Hold down the E key and instead of uselessly repeating the E, it pops up a little GUI for you to choose É or the like. Windows doesn’t really have this (I wonder if Apple has a patent?). The best alternative I’ve found is the Touch Keyboard, which has a similar UI with the mouse.

I miss the emacs editing keys in text areas, particularly Ctrl-E for end of line.

I miss Keychain. I didn’t use it much on the Mac, but having a central system for secrets is really smart. The specific thing I miss using is the SSH agent.

I miss iMessage. It was great getting my phone text messages on my desktop. Apple seems uninterested in opening iMessage to anyone else.

I miss having a brightness control for my monitor from software. There’s no volume hotkeys either. Actually I miss everything about how the iMac integrates display, etc in to the computer. I now have no webcam and no microphone. OTOH my new external monitor is lovely. Better be, it cost half as much as an iMac!

Good things

So those are the gripes. Here’s good things about the Windows switch.

Gaming. That was the #1 reason I switched back to Windows, I wanted to dip back into PC gaming. Apple is simply not competitive in desktop gaming, not in hardware and certainly not in software. Microsoft’s lock-in strategy with DirectX succeeded.

The hardware itself is better and faster. Apple has neglected the iMac line and fallen behind. The GPU is the main thing I have that a Mac can’t do. But it was also nice being able to build a machine with Kaby Lake parts the second week they were available retail. I was also surprised that it was relatively easy to spec a clean, quiet piece of hardware; that used to be a big PC drama. It wasn’t much cheaper than Apple hardware though, particularly when you consider the display.

Network file shares work better. I gave up on using SMB on my Mac when Apple dumped Samba for their own broken SMB implementation. Of course SMB is quite nice on Windows. NFS worked on the Mac but was awfully slow and didn’t include an authentication solution. SMB is grody but seems to work.

My Network printer just worked. I had to do literally zero setup; it was discovered and configured automatically. Not so lucky with the scanner though.

Ubuntu-on-Windows is shaping up to be a good Unix environment, certainly better than MacOS. Here’s a post about it.

 

 

New Windows gaming PC

After five years of running Macs I’m going to try Windows again. I only use the computer in front of me as a fancy terminal, web browsers and SSH sessions mostly. And gaming. But I’m not really using the OS as a real computer, so I can suffer with Windows. Also I’m fed up with a bunch of stuff related to Macs. MacOS is not a very good Unix, I went back to doing all my real work on Ubuntu last year. Mac gaming is just awful. And Apple has apparently abandoned the idea of updating iMac hardware.

Anyway, I ordered a PC. I went full max spec with brand new Kaby Lake parts because I intend to use this machine for 4+ years. Top end CPU, top end GPU, 16GB RAM, 500GB SSD, and some fancier cooling / quiet components. Here’s the parts list.

  • Motherboard:  Asus Z270-P
  • CPU: Intel Core i7-7700K 4.2GHz
  • GPU: EVGA 08G-P4-6286-KR NVIDIA Geforce GTX 1080 FTW
  • RAM: C769-V16B Corsair CMK16GX4M2B2800C14 16GB (2x8GB)
  • Drive: Samsung 960 EVO 500GB PCIe NVMe M.2 SSD
  • Power supply: Corsair CP-9020092-NA RMx RM750X 750W
  • Case: Fractal Design Define R5
  • CPU cooler: Noctua NH-D15S
  • Monitor: Asus ROG PG348Q 3440x1440

So far so good! The motherboard was a compromise, it doesn’t support SLI. The CPU and GPU are too far up on the price vs. performance curve but I was feeling spendy. The case is nice, it has sound baffling. The CPU cooler is absurdly huge; I don’t intend to overclock, but large = quiet.

Shopping for the monitor really made me appreciate what Apple has done with the iMac displays. It’s very hard to find something that quality for PC parts. I decided not to go with the 4k/5k/Retina high density displays, too expensive and no GPU can fill that many pixels in a game.

There’s some neat new things in PC hardware. The M.2 form factor for SSDs dispenses entirely with the history of hard drives, the SSD looks something like a RAM module. (Which begs the question; why are PC cases still so giant? Cooling.) And GPUs have a nice new feature called G-Sync or Freesync. For 20+ years we run the screen at 60Hz and hope the GPU can keep up with 60fps vsync interrupts. Now the GPU just renders frames as fast as it can and the LCD only updates when there’s a new frame to draw.

I had Central Computers build it for me, a local screwdriver shop. They did a great job on the quote and build process for $80 labor plus maybe a 10% markup on parts. The computer priced out about $2150, the monitor $1100. Expensive! But I use this literally all day every day, and like I said I don’t intend to upgrade for a long while.

 

Windows 7 update fixes

I dusted off the old Bootcamp partition to run Windows to play Civilization VI, impatient for the Mac release. Every time I do this I’m reminded how bad Windows is. This time around it was 90 minutes spent trying to install and run the game and failing. I gave up and went to bed, then fixed it in the morning.

The symptom was the installer would hang while installing the Microsoft VC 2015 redist. Cancelling the installer didn’t help. Manually killing the wuas.exe process that was hung did allow the install to complete. But then the game wouldn’t run; you’d launch it and it’d quit immediately with no error. Launching the program manually (bypassing Steam) revealed the error, “api-ms-win-crt-runtime-l1-1-0.dll is missing”.

So then begins the cargo cult debugging. Googling for answers and trying various incantations to fix the mysterious problem.

The first thing I tried was manually installing the VC redists. These installers have always sucked. The end result is it’s copying 20MB worth of shared DLLs into a system directory. Why does it take five minutes? Why does it hang entirely? Running by hand (as opposed to via the game installer) sometimes helps. It didn’t this time, it kept hanging.

So the second thing I tried was fixing that error about the crt-runtime. There’s a consensus in the cargo cult about how to fix this; run Windows Update. But Windows Update wasn’t working for me. This is the moment I confess my copy of Windows 7 isn’t registered with a valid license, I’ve been using the grace period for the very rare times I want to run Windows. My bad. So is it the lack of activation that’s causing the problem? Windows is popping up a nag when I try to run the installers. But there’s no explicit error, the installer just hangs. Trying to install it manually didn’t work either, same hanging on Windows Update stuff.

And then the scales fell from my eyes. Windows Update is broken. A fix was released in April 2015; or maybe not until July 2016. Not sure. Anyway the first step in installing that fix is to stop the Windows Update service. Once I did that the crt-runtime installer worked, copying it’s 800kb file successfully without hanging. Congratulations, l’il fella! And that was enough to fix the problem.

So let me rant and describe all the failure-by-design, from top down:

  • The game crashes on startup with no message.
  • The game installer hangs with no explanation. You can quit the install, but then it’s broken.
  • The underlying VC distributable installers hang with no explanation. Its job is to copy 20MB of files, but it can’t do this.
  • The underlying underlying CRT runtime installer is hanging with no explanation. Its job is to copy 800KB of files, but it can’t do this.
  • The root cause is Microsoft screwed up Windows Update somehow and fixing it is awkward, because it requires Windows Update to install the Windows Update update.
  • And worming its tendrils through all this is Windows Activation DRM, which may or may not be interfering and causing problems. With no explanation.

It really is an awful system.

 

Windows is worse than MacOS

I bitch about MacOS a lot, complaining about the rough edges in what is mostly a good product. But MacOS really is bad at one thing: desktop gaming. Some times I’m tempted to switch back to Windows just so I can play game. This week I was desperate to play Civilization: Beyond Earth before the Mac port is finished. So I booted my Bootcamp partition into Windows for the first time in two years.

Wow, what a terrible experience. Pretty much all the badness centers on software management, installs and upgrades. I was prepared for the initial thing to take forever; it was a two year old Windows 7 image, after all. Some 60+ updates and a few reboots later and all was set up. That wasn’t so bad really.

What was bad was installing software with Steam. In particular, the way you have to “install VC redist”. Steam makes the wise choice to require a separate install for every game, basically the 2014 solution to the 1995 problem of DLL hell. But the installers are fucking ridiculous. It takes 30+ seconds to do the install. What the hell is it doing? Copy a few files, maybe update a registry key or two, and you should be done. And for some reason I had to install like 15 of these for Steam the first time, then another 4 for Civ:BE.

The Bootcamp experience is not good either. The display drivers don’t work perfectly, for instance the sleep mode doesn’t shut the back light off. And I’m scared to try updating the 3 year old driver. You can’t use the vendor display driver, you have to use Apple’s, and all Apple ships is one giant install disc every once in awhile. Two, actually, you have to pick the release based on knowing what model iMac you own. Only iMac’s don’t have model numbers, so you have to remember the year you bought the thing instead.

Windows itself is still mostly, well, Windows. It’s funny how much I’m used to the Mac way of doing things now. I miss my menu bar. I can never tell if Chrome is running and just has no windows, or what. I even hacked the registry to enable reverse mouse wheel. And the stupid system is still prompting me for urgent reboots by switching me out of my full screen game, interrupting me with a popup dialog.

Identifying Windows code page 1252

A blog post I wrote on a foreign laptop ended up with byte values 0x92 for apostrophes and 0x93 and 0x94 for quotes. This is an old Windows “smart quotes” and makes sense in Windows code page 1252. It is not valid ISO-Latin-1; that encoding doesn’t have typographical quote marks in it.

Easy enough to fix once the encoding is identified: “iconv -f windows-1252 -t utf-8”

I should make a website that has one web page per code point. So you could go to a page named “0x92.html” and see what all it translates to in the world’s various codecs. There’s a bunch of one-page-per-Unicode-character sites out there, but I don’t know of a resource that lets you easily guess a mystery encoding by a few examples.

WingIDE 4.0 problem with Python 2.7.1 on Windows

My Python IDE of choice, Wing, has a capability to start the debugger when an exception is raised, but only if it “appears unhandled”. It’s great but a little delicate. It broke entirely on my recently, all exceptions appeared unhandled. I narrowed the problem down to running in Python 2.7.1. Python 2.6 works fine. The workaround Wing recommended was setting the debugger to break when exception is printed.

using git on Windows via SMB

I keep my source code on a Linux machine, but I develop on Windows. The cross-platform thing is a nuisance. I mostly prefer to work in the Unix way, and make Windows cope.

msysgit seems to be the Windows git client of choice. (Cygwin is too foreign an environment). To make it play nicely with Unix systems:

  • core.autocrlf=false
    Don’t ever modify line endings, just accept what’s there. Every Windows editor I use can handle Unix line endings just fine.
  • core.filemode=false
    Don’t mess with file modes. Works around the problem that Samba doesn’t really handle Unix file modes right, particularly +x.  Avoids the problem of “old mode 100755 new mode 100644”.  This probably means you can’t meaningfully set file modes from Windows.
  • gui.encoding=utf-8
    Not strictly a Windows thing, but a good idea.

These can be set via the msysgit bash shell with “git config core.filemode false”. You can see your settings with “git config -l”. There’s something confusing I don’t understand about system/global/local settings that I’m ignoring.

Binding CapsLock in Windows

I wanted to re-use my useless CapsLock key to search Google. I started by modifying WinUrl, an old program I’d used forever. Seemed easy enough, just RegisterHotKey(..., VK_CAPITAL). It even seemed to somehow suppress the capital locking function, all done! Except not, some confusing thing happened where caps would be on in some windows, off in others.

I went down a rabbit hole trying to disable caps locking. It’s buried deep in the drivers somewhere in Windows. The recommended work around is to use SendInput() to fake a new CapsLock keystroke to toggle it back, or maybe SetKeyboardState() to obliterate the CapsLock bit. But about the time I was putting 2 second delays in my code to prevent recursion from triggering my own functions, I gave up on that approach.

I ended up using AutoHotKey instead with this script. I don’t like AutoHotKey, it’s way overengineered. Custom scripting language, custom compiler to native code?! But it’s also very capable. And it knows how to override CapsLock.

Django 1.2 and GeoDjango on Windows

I’ve been trying to develop code on my Windows box. It’s the machine I sit in front of, it’s fast, and I like WingIDE. I have a Linux box for “real work”, but think there’s some discipline in moving back and forth between the two systems.

For GeoDjango hacking I decided to run the PostGIS database on my Linux box and the Django webapp on my Windows box. I’d hoped this would avoid having to install a bunch of funky binaries on Windows. No such luck. The GeoDjango docs are a bit out of date and the official GeoDjango Windows installer binary is for an old version.  Here’s what I’ve learned doing it myself.

The first step is getting regular Django working. Here’s what I did:

  • Installed PostGIS + dependencies on Debian (testing) via
    aptitude install postgresql-8.4-postgis
  • Installed stock Python2.5 on Windows from Python.org
  • Installed Django 1.2 on Windows. I forget how I did this, I think using easy_install, which in turn requires installation as well. It wasn’t hard, just followed the tutorial. Django 1.2 includes GeoDjango Python libraries.
  • Installed psychopg2, the database driver, on Windows. There’s binaries at http://stickpeople.com/projects/python/win-psycopg/

GeoDjango is harder. It relies on a lot of C libraries, some of which don’t support Windows well. The main hurdle is a working GEOS DLL. The GEOS page itself doesn’t have binaries. I found binaries from three places: OSGeo4W,  the GeoDjango Windows Installer, and PostGIS. Here’s a quickie test program I wrote to try them out:

geosPath = r'.\libgeos_c-1.dll'

from django.conf import settings
settings.configure(GEOS_LIBRARY_PATH=geosPath)
from django.contrib.gis.geos import tests
tests.run()

Unfortunately, both the OSGeo4W and GeoDjango versions of the DLL don’t pass the tests. Version skew? Bug? The underlying error seems to be in memory management, something like

ERROR: test02_wktwriter (django.contrib.gis.geos.tests.test_io.GEOSIOTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\Python25\lib\site-packages\django\contrib\gis\geos\tests\test_io.py", line 30, in test02_wktwriter
    self.assertEqual(ref_wkt, wkt_w.write(ref))
  File "c:\Python25\Lib\site-packages\django\contrib\gis\geos\prototypes\io.py", line 147, in write
    return wkt_writer_write(self.ptr, geom.ptr)
  File "c:\Python25\Lib\site-packages\django\contrib\gis\geos\prototypes\threadsafe.py", line 55, in __call__
    return self.cfunc(*args)
  File "c:\Python25\Lib\site-packages\django\contrib\gis\geos\prototypes\errcheck.py", line 87, in check_string
    free(result)
WindowsError: exception: access violation reading 0x02F12494

The library that did work for me was the version that came with PostGIS. I didn’t even install PostGIS, just grabbed the DLLs out of their zipfile. Unfortunately GEOS is spread into two files: libgeos_c-1.dll and libgeos-3-2-2.dll. The latter needs to be in a directory where Windows can find it as a normal DLL, I put it in the working directory of my own code.

GEOS was enough for me to get the tests working and my simple GeoDjango program working correctly. There’s more work to be done: I believe you want both GDAL and PROJ.4 available to GeoDjango on the Windows side. Or does PostGIS do the work on the database server? I haven’t tested that yet.

In addition to basic GeoDjango on Windows setup, here’s notes specific to my code:

  • Followed instructions on getting WingIDE to work with Django
  • Sweated a lot over environment considerations, specifically Python path. I hate setting up new development environments, and Django with its mix of servers and applications and developer code and third party libraries is complicated.
  • I’m trying to run a script directly, not via manage.py. To make that work you need to set the DJANGO_SETTINGS_MODULE system environment variable to point to the Python path of your settings.py
  • settings.py needs to specify a special database engine:
    ‘ENGINE’: ‘django.contrib.gis.db.backends.postgis’

There’s some more useful notes about Windows and GeoDjango in this blog post by Reinout van Rees.

Testing Windows Live Writer

In a bit of a yak shaving exercise, I’m looking for a really simple blog post writer that’s more convenient than using wordpress.com’s web editor. Windows Live Writer works with wordpress.com, how good is its HTML?

$(data).find('option[value^="ruc"],option[value^=eta]').each(
    function(i, e) {
        var timeString = $(e).text();
        var filename = $(e).attr("value");
        r[timeString] = filename;
    });

There’s no support for <pre> tags, but I found a plugin that does it. (Update: not suitable for wordpress.com, since it requires Javascript. Use wordpress.com’s builtin

tag instead) The ribbon UI is pretty bad and there’s a lot of junk between me and my thoughts. But it’s not terrible. Here’s a picture:

5181557705_83c429094f_m