Notes

I haven’t touched the site for pretty long time, but recently after re-installing Linux I’ve decided to update Hugo to latest version, and… found out that my site was broken in serveral places.

  1. I had to move most of the params in language sections to params sub-section. Actually, hugo serve warns about wrongly placed parameters, so it’s not a big problem.
  2. I’ve removed taxonomyTerm from the outputs section in config. As I understood, it’s all merged with taxonomy now, so separate parameter doesn’t make sense.
  3. I had to make category keys in theme to lower case. 0.123.3 has added the capitalizeListTitles option (i.e. font-patching became Font-Patching). For some people it’s conveinent, but for me it broke localization, since it was based on lowercased keys. In truth, making keys lowercased was a rushed decision, because I could just disable an option, but at some point there could be a problem when something somewhere will be in wrong case, and will break everything, so it’s for the better.

But now everything is generated with fresh Hugo 0.126.1, and works as expected. I think I’ll write a theme for Hugo sometime, but I think it won’t happen soon.

Dark window frame on Windows 10

From time to time I’m encountering a problem that app has dark color theme, but window frame is light. So here I’ll save two ways to change it on Windows 10.

For app users

I’ll tell you right away: this way won’t be useful if the accent color is important to you.

Open Registry Editor and find HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\DWM section. You’ll need the following parameters from it:

  • ColorPrevalence: DWORD = 1
    This parameter allows to use accent color as title bar color.
  • AccentColor and AccentColorInactive: DWORD = color in ABGR format (hexadecimal).
    Colors for active and inactive mode.

Here’s an example of registry file where color #000000 is used for active window title and #212121 is used for inactive one:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\DWM]
"ColorPrevalence"=dword:00000001
"AccentColor"=dword:ff000000
"AccentColorInactive"=dword:ff212121

For app coders

You’ll need DwmSetWindowAttribute function:

HRESULT DwmSetWindowAttribute(
       HWND    hwnd,        // window
       DWORD   dwAttribute, // attribute itself
  [in] LPCVOID pvAttribute, // value
       DWORD   cbAttribute  // value size in bytes
);

Attribute values are described by DWMWINDOWATTRIBUTE but we specifically interested in DWMWA_USE_IMMERSIVE_DARK_MODE. Documentation says it’s equal to 20, however until 20H1 version the value has been equal to 19 .

That’s how i’ve tried to implement autodetect of window frame theme in Ultimate++ :

  HRESULT (WINAPI *DwmSetWindowAttribute)(HWND hwnd, DWORD dwAttribute, LPCVOID pvAttribute, DWORD cbAttribute);
  DllFn(DwmSetWindowAttribute, "dwmapi.dll", "DwmSetWindowAttribute");
  if (DwmSetWindowAttribute) {
    BOOL useDarkTheme = IsDarkTheme(); 
    DwmSetWindowAttribute(
      top->hwnd, 20, /* 20 is DWMWINDOWATTRIBUTE::DWMWA_USE_IMMERSIVE_DARK_MODE */
      &useDarkTheme, sizeof(useDarkTheme));
  }

Notes are now shown on home page. At the same time I’ve finished localizations moments and converted RSS to Atom. Moreover, I’ve fixed Atom XML file the way it now shows all content as it should look as far as it possible.

It seems that only thing left to me is to make yourself an editor or at least button to add/update posts. Still, it’s not convenient to do it through SFTP. Time and date are written manually as well.

Probably this is what’s stopping me to write here frequently, so when I’m starting to write, the posts become longer than I expect.

But with notes probably blog will be more lively. Articles won’t go anywhere though, you can subscribe to them by RSS separately. Or only to notes. Or to notes with tag.

I’m also thinking to make something for small posts, like self-hosting some ActivityPub server. In that case though it will be a small server, because there is not much RAM on this VPS. But that’s under question.

Since I’ve started localization talk, this note will be devoted to localization. To be honest, I’m not sure since what version this happened, but localization in Hugo has greatly stepped forward.

First, Hugo now natively supports plurals for many languages. All thanks to https://github.com/gohugoio/go-i18n module (fork of https://github.com/nicksnyder/go-i18n ). Usage is very simple: create reqired keys in localization file and translate them. Here’s current list for reference (with two-letter language codes): https://github.com/gohugoio/go-i18n/blob/main/v2/internal/plural/codegen/plurals.xml

Second, Hugo can now localize dates through time.Format DATE_FORMAT DATE. I’ve rewritten templates a little, and now places with dates from these:

{{- with .Site.Params.dateformat | default "2006-01-02" | .PublishDate.Format -}}

became these:

{{- with time.Format (.Site.Params.dateformat | default "2006-01-02") .PublishDate -}}

Category and meta tags localization I had to done on my own. They may not fully work with new section though, but I’ll fix it sometime.

I’ve updated the site a little: fixed some theme and localization stuff. Also, as you can see, I’ve made a new section: notes.

What is it like? It’s something like my own simple microblog without any backend. It’s easier for me to make some small notes than to write full articles, and it suites these cases very well.

Of course the deployment like this affects social part, but I can duplicate posts somewhere if necessary. This way, there is the RSS feed (this button from top right), so you can subscribe in any RSS reader that is convenient to you.