Uniform look for Qt and GTK applications

See: https://wiki.archlinux.org/title/Uniform_look_for_Qt_and_GTK_applications

Theme: The custom appearance of an application, widget set, etc. It usually consists of a style, an icon theme and a color theme.
Style: The graphical layout and look of the widget set.
Icon Theme: A set of global icons.
Color Theme: A set of global colors that are used in conjunction with the style.

Actually a theme also controls native dialogs, like open file dialog. How to write a Qt style is covered here.

I’m running Linuxmint 22 with Arc theme on my desktop. Fusion theme is used by default for Qt applications. They removed qt5ct in Linuxmint 22 by fresh install. But it seems to be the best solution so far. Following is a comparison among the possible apporoaches, when run a Qt application. Which means runing by:

  has theme? has style? QT_QPA_
PLATFORMTHEME
QT_STYLE_
OVERRIDE
Description
Gtk2 Yes Yes gtk2 gtk2 or empty Good for widgets, indicators in radio button and checkbox can be styled, follows current Gtk theme. But It has HiDPI issues, and certianly not maintained.
Gtk3 Yes No gtk3 or empty values in qt5ct No style plugin. Fusion is used by default, which is not consistent with other themed Gtk applications.
qt5ct Yes Yes qt5ct values in qt5ct No style plugin, Fusion is used by default, which is not consistent with other themed Gtk applications. Color scheme and font can be further customized. Button indicators are not styled.
Kvantum Yes Yes qt5ct kvantum Use Kvantum Manager to further customize the theme. Button indicators are styled. KvArc theme is provided, but is still somehow different in visual. Kvantum also installs several KDE component, which is odd.

So my final solution is: using qt5ct with customized color scheme and font. Color scheme defined:

Copy those 2 file into ~/.config/qt5ct/color, open qt5ct:

  • Go to Appearance –> Platte –> Check custom and select arc.
  • Go to Fonts –> Select your Gnome/Cinnamon font.
  • Go to Icon Theme –> Select your Gnome/Cinnamon icon theme.
  • Open ~/.config/qt5ct/qt5ct.conf, change standard_dialogs=default to standard_dialogs=gtk3.

See the difference:
vlc_default
vlc_themed

Upgrading Ubuntu 24.04 Network Configuration

Debian/Ubuntu and RHEL/AlmaLinux have different network configuration utilities. RHEL 9 has deprecated ifcfg-files, and adopted NetworkManager. There is no ifup or ifdown any more after a fresh installation. Since my server was first installed using Ubuntu 14.04, it still uses these scripts. Time to move on.

1. ifupdown

Netplan is used to configure networking in Ubuntu 18.04 and later. Ubuntu Server is packaged with systemd-networkd as the backend for Netplan, while NetworkManager is used as the Netplan backend in Ubuntu Desktop. Install by:

Get current network status by:

eth0 is unmanaged, since ifupdown is used. The config file is /etc/network/interfaces.

2. networkd

Create a config file /etc/netplan/50-cloud-init.yaml

This file is create by cloud-init if fresh installed. I kept the name. networkd comes with systemd, no need to install it again. Apply it by:

Now, eth0 should be managed by networkd:

The generated config file can be found in /run/systemd/network/10-netplan-eth0.network. System config files located in /etc/systemd/networkd.conf & /usr/lib/systemd/network/.

3. NetworkManager

NetworkManager can also be used for servers. Install by:

Create a config file /etc/netplan/01-network-manager-all.yaml.

This file is create by Ubuntu installer if fresh installed. I kept the name. Verify the merged config by running:

NOTE, one additional step need to be performed, /etc/network/interfaces must *not* exist. NetworkManager has a plugin to parse the file. Backup it, so that you can roll back to ifupdown if something goes wrong. Apply it by:

Now, eth0 should be managed by NetworManager:

The generated config file can be found in /run/NetworkManager/system-connections/netplan-eth0.nmconnection. System config files located in /etc/NetworkManager/NetworkManager.conf & /usr/lib/NetworkManager/. On systems before RHEL 9, /run may be /var/run. When NetworkManager starts and finds no connection for a device it might create an in-memory connection. No config file is created. The no-auto-default configuration disables that behavior. Check systemd log for details:

More info can be found in Debian documents. Useful commands include: NetworkManager --print-config, nmcli device & nmcli connection.

4. Clean ups

Now, you can safely remove ifupdown, and the networking systemd service will be removed too.

5. iptables

An ifupdown script was add to persist iptables rules.

This can be migrated by installing iptables-persistent:

Keyboard Backlight Control on Lenovo Ideapad & Xiaoxin Models

Ever found the keyboard backlight annoying? It keeps turnning on when booting Windows, and there is no configuration to disable it permanently in any Lenovo Utilities.

Just did some reverse engineering to find how to control keyboard backlight programmatically. The principal is simple, use \\.\EnergyDrv device exposed by Lenovo ACPI energy management driver. It is capable of controlling all keyboard backlight levels. Also other capabilities available 🙂 . See code:

Should built and run on any C99 compilers. Run with <app.exe> [0|1|2|3]. You can add it to task scheduler to disable keyboard backlight on startup.

Also checked other approaches. The usb/hid way does not work on an ideapad. The Keyboard_Core.dll hack also does not work, I cannot find the file in drivers.

11 Years of My Site

As the recored by Linode, the site server was first lauched on Apr 1, 2014. It was running Ubuntu 12.04. Later I setup wordpress and moved my blog here from blogspot on Aug 16, 2024. Spurious Wakeups was my first post. Now, the server is running Ubuntu 24.04, and is using catch box theme with css customization:

Just updated all plugins and found 3 problems.

1. Google Analytics 4

Google fully replaced Universal Analytics with Google Analytics 4 on July 1, 2024. Just noticed that, all visiting history are lost 🙁

2. Fail2ban not working

Fail2ban is not working anymore, due to the switch from iptables to nftables in Ubuntu 21.10. So it has broken for about 2 years, since my last upgrade to Ubuntu 22.04. Found the issue by running fail2ban-client -d. Simply revert the change in config sudo vi /etc/fail2ban/jail.d/defaults-debian.conf.

Since Fail2ban also updated its default backend from pyinotify to systemd(see above), backend should be also reverted in wordpress config sudo vi /etc/fail2ban/jail.d/wordpress.conf.

Make sure package python3-pyinotify and python3-system are installed. Restart Fail2ban.

3. Akismet not working

Akismet is reporting 500 errors. Details are found in logs: .../plugins/akismet/.htaccess: Require not allowed here. This is sloved by adding config to apache server to allow AuthConfig, in both http and https config files.

Redis Alternatives and Relates

1. Tendis

From Tencent, based on RocksDB as persistent storage. Binlog to support resuming transport when running replication.

2. Kvrocks

Apache project, poor document. Have seen no advantage over Tendis so far. Also based on RocksDB.

3. KeyDB

Redis fork, multi-threading adopted.

4. Codis

A Redis proxy, clients are not required to know the cluster protocol.

5. redis-cluster-proxy

A Redis proxy, clients are not required to know the cluster protocol.

6. RedisShake

Redis data synchronization(Cross DC). Launch multiple process if sync source is a cluster setup. Used for one-shot full sync scenario, not recommanded for long-time incremental sync.