Fixing Hotplug for the ATI Remote Wonder II on X11

EDIT: It turns out hotplug wasn’t the problem. Something else is resetting the X11 keymap without it involving the device getting reset… I’m done with this nonsense. I’ll temporarily set a user cronjob to force it back to what it’s supposed to be and then, when I have a moment, replace xbindkeys with a udev rule to loosen the security on the ATi Remote Wonder’s evdev node (it’s not as if I’ll ever be entering sensitive data using it) and a custom quick-and-dirty runs-in-my-X11-session daemon to listen to the raw evdev input events and react to them. (Sort of a knock-off LIRC for something the kernel driver exposes as a keyboard and mouse.)

EDIT (The following day): Instead of going through all this mess, just bypass the nonsense. Install xremap, set a udev rule like SUBSYSTEMS=="usb", ATTRS{idVendor}=="0471", ATTRS{idProduct}=="0602", MODE="0664", create your mappings somewhere like ~/.config/xremap.yml, and then add an autostart entry for your desktop that says sh -c "exec xremap ~/.config/xremap.yml --watch=device --device 'ATI Remote Wonder II'". That way, you’re binding directly against the evdev symbols and you have the ability to keybind to things like “A, but only from the remote, not the keyboard”, which is a big hassle otherwise. Its support for application-specific keybinds even has support for Wayland if you’re using either GNOME Shell, KWin, or something wlroots-based as your compositor.

If you’ve got an ATi Remote Wonder II and you’re using an X11-based desktop, you might have noticed that it’s a bit of a hassle to get the mappings to stick for the buttons with keycodes outside the 0-255 range that X11 supports.

First, you need to remap them into the range the X11 core protocol supports, which isn’t that difficult if you’re familiar with writing udev rules

# /etc/udev/rules.d/99-ati-remote-wonder-ii.rules
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0471", ATTRS{idProduct}=="0602", RUN+="/usr/bin/setkeycodes 0x005C 28 0x015C 28 0x025C 28 0x035C 28 0x045C 28 0x0020 192 0x0120 192 0x0220 192 0x0320 192 0x0420 192 0x0021 19
3 0x0121 193 0x0221 193 0x0321 193 0x0421 193"

…but the range from 0-255 makes it kind of difficult to find keys that both have a default X11 keysym mapping and don’t have some kind of predefined behaviour attached to them, such as altering the volume.

With Kubuntu Linux 20.04 LTS, the above line was enough but, when I upgraded to 22.04 LTS, something broke my mapping for a “trigger the talking clock from bed and log the time I asked” button.

KDE lacks the ability to do what I want through the GUI, custom keymaps are practically undocumented and apparently require editing stuff under /usr to boot, and I couldn’t just run xmodmap once a minute on a cronjob, since that exacerbated a reset bug that shows up with X11+my USB-PS2 adapter+my pre-2013-layout Unicomp keyboard, so that left me with only one option: Figuring out the “in an X11 session” equivalent to udev‘s RUN+= construct.

Enter inputplug. It’s included in the Ubuntu repos and it’s a daemon which will run a script every time the XInput hierarchy changes.

Here’s the little script I wrote (based on the usual boilerplate template I start all my Python scripts from), to fire off an xmodmap every time some kind of USB hiccup resets the ATi Remote Wonder II’s key mapping:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Helper to apply xmodmap settings every time USB connectivity for the
ATi Remote Wonder II hiccups and resets them.
"""

__author__ = "Stephan Sokolow (deitarion/SSokolow)"
__appname__ = "inputplug command for ATi Remote Wonder II"
__version__ = "0.1"
__license__ = "MIT"

import logging, os, subprocess, time
log = logging.getLogger(__name__)


def main():
    """The main entry point, compatible with setuptools entry points."""
    from argparse import ArgumentParser, RawDescriptionHelpFormatter
    parser = ArgumentParser(formatter_class=RawDescriptionHelpFormatter,
      description=__doc__.replace('\r\n', '\n').split('\n--snip--\n')[0])
    parser.add_argument('-V', '--version', action='version',
      version="%%(prog)s v%s" % __version__)
    parser.add_argument('-v', '--verbose', action="count",
      default=2, help="Increase the verbosity. Use twice for extra effect.")
    parser.add_argument('-q', '--quiet', action="count",
      default=0, help="Decrease the verbosity. Use twice for extra effect.")
    parser.add_argument('event_type', action="store")
    parser.add_argument('device_id', action="store")
    parser.add_argument('device_type', action="store")
    parser.add_argument('device_name', action="store")

    args = parser.parse_args()

    # Set up clean logging to stderr
    log_levels = [logging.CRITICAL, logging.ERROR, logging.WARNING,
                  logging.INFO, logging.DEBUG]
    args.verbose = min(args.verbose - args.quiet, len(log_levels) - 1)
    args.verbose = max(args.verbose, 0)
    logging.basicConfig(level=logging.DEBUG,
                format='%(levelname)s: %(message)s')

    if args.device_type != 'XISlaveKeyboard':
        log.debug("Skipped event from device (type != XISlaveKeyboard): %s",
            args.device_name)
        return
    if args.device_name != 'ATI Remote Wonder II':
        log.debug("Skipped event from device (name != ATI Remote Wonder II):"
            " %s", args.device_name)
        return
    log.info("Calling xmodmap after 1-second delay")
    time.sleep(1)
    subprocess.check_call(['xmodmap', os.path.expanduser('~/.xmodmaprc')])


if __name__ == '__main__':  # pragma: nocover
    main()

# vim: set sw=4 sts=4 expandtab :

Yes, the time.sleep(1) is a hack, but I just don’t have time to be that correct about it. You run it by putting it at ~/bin/set_xmodmap_for_remote.py, chmod-ing it executable, and launching inputplug -0 -c ~/bin/set_xmodmap_for_remote.py.

(The -0 makes inputplug act as if all input devices were hot-plugged after it launched, so you don’t need to pull and plug the remote’s receiver on boot to get the initial xmodmap.)

Just run that on login through whatever approach your desktop prefers and you should be good.

I’m partial to putting this into ~/.config/autostart/inputplug.desktop rather than puttering around with the GUIs:

[Desktop Entry]
Version=1.0
Type=Application
Name=inputplug
GenericName=XInput Hierarchy Change Handler
Comment=Restore xmodmap changes after ATi Remote Wonder hotplug
Exec=sh -c "exec inputplug -0 -c ~/bin/set_xmodmap_for_remote.py"
StartupNotify=true
Terminal=false

(The sh -c "exec ..." hack is needed because .desktop files don’t support ~ or $HOME otherwise and I don’t want to hard-code the path to my home dir.)

I have noticed a weird thing in testing where the first input event from the remote after a hotplug isn’t subject to the changed settings, no matter how long I wait before trying, but I’m not sure how to diagnose it so we’ll just stop here for now.)

Posted in Lair Improvement | Leave a comment

Fanfiction – Taylor Varga

Taylor Varga by mp3.1415player

Length: 2,058,592 words
Status: Ongoing
Crossover: Worm + Luna Varga (but with the assumption nobody but the author has seen Luna Varga)

Today’s fic is a doozy and not just for its eye-opening length. Like the stories by mp3.1415player on my review TODO list, it’s excellent on its own merits. (Among other things, it feels as if at least 95% of all memorable moments in the Worm fanfiction I’ve read come from this story.)

Being so long, it’s one of those stories where more than just the plot evolves over time… so I’ll discuss it in segments. There will be things that are technically spoilers but, because this fic is so much about the journey, I don’t think knowing the high-level details ruin anything.

When things start out, it’s Yet Another Alternative Trigger Fic (Buffy the Vampire Slayer fandom has YAHF (Yet Another Halloween Fic), so I think I can make a mild commentary on the prevalence of alternative triggers). Being a Luna Varga crossover, as you might expect, Taylor winds up stuck with a tail and body-sharing with/changing into a Godzilla knock-off.

However, that’s where things diverge. If there’s one summary that would fit the entire story, it’s “What would happen if you dropped an Outside Context Problem into the Worm setting on the side of good?” …very much so. Taylor Varga is essentially a fix-fic that doesn’t feel like a fix-fic. It’s a story that could be summed up as “destiny trolls the Worm setting”. It’s a light, character-centric story that’s a lot of fun.

Just look at what Director Piggot has to say about informing the Chief Director:

“I was really hoping to have more to tell her than ‘I don’t know what the fuck is going on but it’s scaly and snickers a lot‘ though. Never mind this entire damn Coil problem.”

Taylor Varga, Chapter 98

…and yes, them thinking that Coil is a problem is a result of Coil’s problem status being neutralized. More specifically, because Taylor is now bonded to a magic alien dinosaur demon, she doesn’t quite follow the same laws of physics anymore, which causes a ton of problems for any thinker abilities that would otherwise make it difficult to write a fix-fic which runs off the canon rails as gleefully as this one does over its couple-million-word run. In Coil’s case, he spends the first half of the fic hiding in his bunker, bothering nobody, as he desperately tries to figure ouy why timelines where he meddles keep ending in black voids.

Of course, it it were just a Luna Varga crossover, that’d be too simple. Whatever “Greater Power” decided to hijack Taylor’s trigger event also unshackled Varga’s abilities… watch out Brockton Bay, Taylor Hebert is now an infinitely variable dinosaur (her words, not mine) with a human-form tail hidden under a magical Somebody Else’s Problem Field and a permanent new best friend with a questionable sense of appropriate humor.

So, yes. Stage one in the story is Taylor Hebert or, more correctly, “Saurial” the anthropomorphic velociraptor girl, wandering around Brockton Bay and stopping crime she bumps into while she gets used to her changed situation… and then starting to experiment with other forms. Enter PHO. Playing into people’s preconceptions because it’s fun and/or helps keep a secret identity will be a recurring theme.

Combine that with yet another twist on “The locker incident leads to Taylor and Danny manoeuvring Blackwell into a corner” and Taylor winds up at Arcadia where a chance encounter (Amy Dallon trips over Taylor’s invisible tail and then Taylor unknowingly gives her a glimpse at her biology when offering her a hand up) and Taylor’s ambient Outside Context Problem-ness (which will be lampshaded later) lead to a new friendship for Taylor and Panacea finally accepting the idea that she needs some “me time”.

Throw in an incident with Taylor saving the Undersiders from Lung, and the stage is set for phase 2.

In Phase 2, Amy Dallon gets talked into actually using her abilities and, before you know it, Ianthe (Amy) and Metis (Lisa), the reptilian exo-suits made from repurposed onion biomass, are wandering around and PHO is inadvertently helping them to build a backstory about The Family, a species of reptilian aliens from deep time who H.P. Lovecraft might have taken inspiration from.

Phase 2 also involves a lot of “Let’s use fix-fic as a vehicle to troll the setting by way of varga magic” humour, including a supermaterial Varga can conjure up that he only knows as “the good stuff”.

This is also a fic where Taylor is so good at math that she arrives at Vista’s powers from another direction, and then makes a “desktop R’lyeh” as a gag gift for Danny which inspires Vista to unintentionally traumatize her classmates and teammates by discovering how to create Lovecraftian “monstrous geometry” using only a pencil and paper… and one where Taylor helps Amy realize that, if she creates a bioconstruct to do it for her, she can enhance herself, including her brain, and do so without the risk of wrecking something. (Something which, combined with Taylor bringing novelty wherever she goes, makes the shards of all Taylor’s growing circle of cape friends very happy… though Lisa isn’t particularly pleased with how much she’s inadvertently taught hers to feel smug when they start to sense their presence.)

Basically, once the story really gets going, it’s a fun character piece about three smart, wildly OP young women with offbeat senses of humour (one of whom is still clinging to the idea of being “the normal one”) slowly fixing the Worm setting with the power of trolling, confusion, unknowingly having moments of comically good luck, being genuinely good people, and being so visibly OP in their alternative identities that it completely stymies people who would plot against them.. (Gotta love stories where people are unarguably OP but it doesn’t hurt the story because “not even Superman can punch clinical depression”.)

If you’re thinking this sounds vaguely reminiscent of stories like Make A Wish by Rorschach’s Blot which rely heavily on “humour based around a gigantic misconception and that misconception slowly becoming reality by default”, you’d be right and this also inspired a slew of third-party contributions. In later chapters, look forward to omakes like “Saurial is not pleased that Odin from the Marvel Cinematic Universe is claiming her old hammer (Mjolnir) to be his own work” and spin-offs like The Long Slow Lizarding of Hermione Granger.

So, what would I rate it? Well, it gets a bit slow around the bit when they finally go in to dig out Coil, and I do think the omakes got a bit too numerous at points, but, overall, it’s still good enough that I’d probably give it a 4.9 out of 5. Definitely would recommend.

Posted in Fanfiction | 2 Comments

Vorke V1 Plus Thermal/Fan Fix for Linux

If you have a Vorke V1 Plus that doesn’t want to drive its fan under Linux, or which doesn’t want to shut off the fan after the UEFI turns it on at boot, here’s what worked for me:

  1. Make sure you’ve got a kernel version that allows you to manually control the fan via one of the /sys/class/thermal/cooling_deviceX/cur_state nodes. Debian bookworm’s default 6.1.0-13 kernel had problems with that while my Ubuntu 22.04 LTS flash drive’s 6.2.0-16 didn’t, so I wound up pulling one of the 6.5.0 kernels from Debian backports.)
  2. Make sure thermald is installed. My experience is that, without it, the Vorke V1 Plus will just leave its fan on whatever the UEFI set it to, no matter how high or low the CPU temperature goes.
  3. Write this configuration into /etc/thermald/thermal-conf.xml:
    <?xml version="1.0"?>
    <ThermalConfiguration>
    <Platform>
    <Name>Prefer fan over thermal throttling</Name>
    <ProductName>*</ProductName>
    <Preference>PERFORMANCE</Preference>
    </Platform>
    </ThermalConfiguration>
    As far as I can tell, thermald on Debian bookworm defaults to <Preference>QUIET</Preference>, which means “Thermal throttle as much as you need to in order to avoid spinning up the fan”.

    (Which is a neat option for things with shrill fans like the Vorke V1 Plus if I can figure out an easy way to toggle it… maybe reassign the power button from “request a clean shutdown” to “toggle cooling between performance and quiet”.)

    There’s probably some other way you’re meant to do this, and I welcome comments from people who actually know how this is supposed to work, because I found thermald to be frustratingly under-documented.
  4. Run systemctl edit thermald.service and paste in these lines:
    [Service]
    ExecStart=
    ExecStart=/usr/sbin/thermald --no-daemon --dbus-enable --exclusive-control --config-file=/etc/thermald/thermal-conf.xml
    Without --exclusive-control, I found thermald still allowing temperatures to shoot up without enabling the fan.

As for --config-file, the manpage says /etc/thermald/thermal-conf.xml should be in the default search path, but, without specifying it explicitly, I was still getting no effect, despite neither of the higher-priority paths existing.

  1. Reboot (instead of just restarting thermald) to make sure all changes will persist as intended and stress-test the CPU with something like stress --cpu 4.

If you still have trouble, try toggling DPTF enable/disable in the UEFI settings. (hold Delete while powering on, and then go into Advanced > Thermal.)

I don’t know if playing around with DPTF is necessary with the Vorke V1 Plus, but I also have a Vorke V1 and I needed to toggle it on that one so I could memtest86 the RAM upgrade I put in without the thing slowly overheating.

Posted in Geek Stuff | Leave a comment

How to remove pcANYWHERE32 v8.0 from Windows XP

…so you naively thought that continuing past the Windows XP compatibility warning and installing pcANYWHERE 8.0 would give you a working pcANYWHERE client but no server?

…and you now have a machine that just boots into a black 640×480 screen which ignores Ctrl+Alt+Delete but does let you move the mouse?

…even if you choose to boot into Safe Mode?

Here’s how I recovered my Windows XP retro-machine without undue pain:

  1. Pull up the “Windows Advanced Options Menu” (Hit F8 after your BIOS hands off to Windows but before the boot logo appears… I just tap it repeatedly.)
  2. Choose “Last Know Good Configuration (your most recent settings that worked)”
  3. You’ll probably get a working boot with auto-login temporarily disabled. I just hit Enter with the username it pre-filled and no password.
  4. Use Add/Remove Programs to uninstall pcANYWHERE.
  5. To be sure you’ve gotten rid of it, go into System Restore (Start > Applications > Accessories > System Tools > System Restore) and roll your system configuration back to the most recent System Restore point.

That should do it.

TIP: If you can’t get F8 to work, make sure you’re using a PS/2 keyboard, not a USB one.

(If your BIOS doesn’t have working USB→PS/2 keyboard emulation, the Windows boot menu won’t see your input either because it happens before Windows’s own USB HID drivers get loaded. This confused me for a moment, before I realized I’d never needed to go into the BIOS setup or boot menu, or access the Windows boot options since I switched to a USB+VGA KVM switch to let it share the desk with my Power Mac G4.)

Posted in Retrocomputing | Leave a comment

Fanfiction – That Sounds Like Work

How does a completed Worm crackfic based around Taylor Hebert triggering with superpowered laziness sound?

What about a fic with bits like this?

“You let my brother hijack your body… so you don’t have to walk?” said Cherie with an incredulous tone.

“Of course! Have you tried walking? You have to pick up your leg off the ground and everything! The worst bit is that you have to do that over and over again if you want to get anywhere. The mere fact that walking exists proves that there is no such thing as an all-loving God! Man invented the wheel thousands of years ago just so we wouldn’t have to do the devil’s work anymore!” she ranted. This girl was a nut bag. Where did Jean-Paul even find her?

If it sounds good, it’s That Sounds Like Work by Flabbyknight.

…spoiler alert: It starts with her beating Emma by being too super-apathetic (i.e. too lazy to care), driving Emma into such fits of frustration that the Winslow staff can’t help but respond.

In the spirit of the story’s premise, I won’t go on in more detail as I usually would (though I will say that the first chapter, as entertaining as it is, isn’t representative of the heights of crackfic-ness that it grows into) and I won’t take the time to figure out where above 4.5 it belongs on my rating scale.

…but I will say that I loved it and It also won second place in the Crack/Humor category in /r/WormFanfic’s Best of 2019 list.

Posted in Fanfiction | Leave a comment

Quick tip for RetroArch’s DOSBox-Pure core

If you’re trying to set up DOS games like Jetpack in something like RetroPie or Batocera, you might run into a problem where pressing the S key (“start new game” in Jetpack) doesn’t do anything, whether through a physical keyboard or through padtokey mappings.

This is most likely because RetroArch’s default hotkeys map S to one of the buttons on the virtual gamepad. (A decision which makes sense for consoles, where you need a gamepad and a keyboard is optional at best, but makes no sense for retro computers, where a keyboard is standard or even built-in, and a joystick is optional)

While I don’t know about RetroPie, under Batocera, the simplest solution is to add the following lines to your /userdata/system/batocera.conf to disable those mappings:

dos.retroarch.input_player1_a=nul
dos.retroarch.input_player1_b=nul
dos.retroarch.input_player1_x=nul
dos.retroarch.input_player1_y=nul

Then, if you do need mappings for DOS games, they probably go the other way (making the gamepad fake keypresses) and can be handled via padtokey mappings.

Posted in Retrocomputing | Leave a comment

Fixing Applications Which Resist Feeling Platform-Native

NOTE: I will update this post as I run into more application frameworks which need a little encouragement to feel native on my KDE desktop. While a lot of the technologies covered are strongly associated with Linux, they do still tend to be portable, so this information isn’t exclusively for Linux.

It seems like, these days, the rise of Electron and other web-based application toolkits has emboldened every two-bit UI designer to forget that the point of a user interface is to fade into the background and let the content gain full focus. (And that means consistency is paramount.)

I won’t go into detail on that, given that others have already done that:

It doesn’t help that everyone (including Apple) seems to have forgotten Joel Spolsky’s Things You Should Never Do, Part I and that the computing world in general has been sliding in this direction since 2002.

…but it is still my computer, and I still have to live with it… so here’s a reference for how to apply UI customizations to various applications and UI toolkits as an end-user.

Firefox

Call me crazy, but I have to wonder what’s going on at Mozilla headquarters that nobody seems to have asked “Is it possible that making our UI chrome feel less similar to platform-native UI than Google Chrome’s, and grabbing user attention with whizbang elements of dubious value… is hurting our user appeal, not helping it?”

Anyway, here’s a summary of the relevant guides on /r/FirefoxCSS (See also userChrome.org):

  1. Enable userChrome.css:
    • Open up about:config and set toolkit.legacyUserProfileCustomizations.stylesheets to true
    • Create chrome/userChrome.css inside your profile folder (There’s a button to open a file browser window for your profile inside about:support but I somehow broke it while locking down my Flatpak install of Firefox further.)
  2. Enable the browser inspector:
    • Open the developer tools (Ctrl + Shift + I on Linux or Windows), open Settings (the cog which may be inside the overflow/… menu), and enable “Enable browser chrome and add-on debugging toolboxes” and “Enable remote debugging”.
    • Restart Firefox
  3. Write your CSS tweak:
    • Press Ctrl + Alt + Shift + I and choose OK in the “Incoming Connection” dialog (It will probably have appeared behind the unnamed, empty window which will become the browser inspector)
    • You will now have something that looks like the browser’s developer tools but lets you inspect and manipulate the browser’s UI instead. It’ll initially be an ugly vertical split with a log on the left but that will eventually go away. (I don’t know how to make it go away faster)
    • Use the “Inspector” tab to identify what to change
    • To actually make changes, select “Style Editor” and use the “Filter style sheets” field to find userChrome.css. This way, if you like the changes, all it takes to persist them is to click “Save” in the userChrome.css entry in the vertical tabs down the left side.

Here are a few examples of tweaks you can create:

/* Remove pointless thumbnail in the Bookmark popup
   (Why?! You can always see the full version while bookmarking anyway.) */
#editBookmarkPanelImage,
#editBookmarkPanelFaviconContainer {
  display: none !important;
}

/* Hide "Saved to Library!" bookmark confirmation popup
   (The star in the address bar having stayed filled already says that.) */
#confirmation-hint {
  display: none !important;
}

/* Compact sidebar header to match my compact toolbars
 * BUG: https://bugzilla.mozilla.org/show_bug.cgi?id=1435184 */
#sidebar-header {
  height: 32px !important;
  padding: 0 !important;
  font-size: 12px !important;
}

Thunderbird

All the same steps as with Firefox apply (including the caution that the “Incoming Connection” dialog will probably fail to put itself at the top of the window stack), but the means to enable things are in slightly different places. (Thanks to this Superuser Q&A and this /r/Thunderbird thread for helping me piece things together)

  • To access about:config so you can enable toolkit.legacyUserProfileCustomizations.stylesheets, go into the “General” page of settings, scroll down to the bottom, and click the “Config Editor…” button.
  • Instead of typing about:support into the address bar, you can find the button to open your user profile to add chrome/userChrome.css under Help > More Troubleshooting Information.
  • The option to open the developer tools is at Tools > Developer Tools > Developer Toolbox

An example customization you can create would be this:

/* Override the horrendous UI font that Thunderbird suddenly started choosing
   (i.e. Match Qt, GTK+ 2.x, and GTK 3 apps)  */
* {
   font-family: "Noto Sans", "Nimbus Sans L", "Droid Sans", sans-serif !important;
}

NOTE: As of at least Thunderbird version 115, you’ll want to remove the @namespace line from any suggested userChrome.css content or you’ll be fighting an uphill battle to apply changes to the increasing number of elements of Thunderbird’s UI that are HTML instead of XUL.

GTK 3+

Starting with GTK 3, the GNOME people and I have… differences of opinion… made worse by how the links I started with find more fodder in GTK 3 than any other system. While I’ve managed to replace most GTK applications on my desktop with Qt equivalents by now, there still exist a few of them (eg. Inkscape) with no viable replacements.

While such apps are, thankfully, not trying to embrace GNOME-isms that run counter to hard-won design principles from HCI research, they’re still being dragged along for the ride by the GNOME-isms creeping into GTK components outside libadwaita.

  • Archlinux Users: If your intent is to make your GTK 3 stuff feel more native on a non-GNOME desktop, start by installing the gtk3-classic package from AUR. It contains a GTK 3.x patched to revert some of the hard-coded GNOME-isms.
  • Other Distros: If your goals include disabling some visual inconsistency caused by GNOME applying client-side window decorations (eg. drop shadows on context menus), gtk3-nocsd will resolve that… but it is an LD_PRELOAD hack, and getting it to work reliably when Flatpak isn’t designed to allow LD_PRELOAD hacks is iffy, so I’d suggest using it as a last resort.

Settings

No matter how much user-hostility we may feel is present in the GNOME developers’ behaviour these days, they do still allow some customization, so always check that before getting hacky.

For GTK 3, settings are customized by putting lines like gtk-dialogs-use-header=0 into ~/.config/gtk-3.0/settings.ini. For GTK 4, it’s ~/.config/gtk-4.0/settings.ini.

Valid settings.ini keys are documented as properties under the relevant GTK version’s GtkSettings API documentation. (eg GtkSettings for GTK 3)

Here are some suggested changes mentioned on Archwiki:

  • gtk-can-change-accels = 1 is a deprecated GTK 3 option that lets you hover your mouse over a menu item and then press a hotkey to assign to it.
  • gtk-toolbar-style=GTK_TOOLBAR_ICONS is another deprecated GTK 3 option that will give you icon-only toolbar buttons without needing to reach for the CSS overrides (That’s what tooltips are for, don’t you think?)
  • gtk-overlay-scrolling = false is listed as API-unstable, but should replace those touchscreen-style overlay scrollbars with ones where you don’t need to wiggle the mouse to see what your current scroll position is.

There’s also the gsettings set org.gtk.Settings.FileChooser startup-mode cwd command (which you may need to run inside your Flatpaks) to restore the “old-fashioned” behaviour of having GTK file chooser dialogs start in the current directory rather than the recent files list.

Themes

Flatpak should automatically install the Flatpak version of whatever GTK theme you’re using but, if it doesn’t the first two things to try are:

  • Make sure whatever settings daemon your desktop uses is installed and running. If the active theme isn’t being announced, then flatpak upgrade can’t install it.
  • It’s possible your theme hasn’t been packaged for Flatpak. The Stylepak tool will grab whatever GTK theme is active on the host and construct a Flatpak package from it.
  • There’s currently a bug that can cause Flatpak’d GTK applications to revert from Breeze to Adwaita on KDE desktops. To work around it, just go into the Application Style system settings module, click the Configure GNOME/GTK Application Style... button, fiddle around with one of the drop-downs to enable the Apply button, put the themes back to what you want, and click Apply. (I haven’t yet investigated a permanent fix.)
  • According to this thread, there are situations where a customized Breeze color scheme (I just use the default) won’t get applied to GTK 3 apps, and the workaround is a global filesystem override (either via Flatseal or manually editing ~/.local/share/flatpak/overrides/global) to grant access to filesystems=~/.local/share/icons:ro;~/.themes:ro;~/.icons:ro;xdg-config/gtk-3.0:ro;
  • libadwaita-based apps aren’t meant to be themed beyond the light/dark switch and the recolouring API they eventually want to add, but, if the theme was designed to support it, you can force the issue by setting the GTK_THEME environment variable. I recommend doing it on a per-application basis rather than globally.

Open/Save Dialogs

This is one area where things are actually getting better for desktop consistency and user customization instead of worse. If your goal is to get all apps using the same desktop-provided Open/Save dialogs, the GNOME people are on board with that. Thanks to the XDG Portal system, anything that uses GtkFileChooserNative (GTK 3) or GtkFileDialog (GTK 4) instead of GtkFileChooser (holdover from GTK+ 2) is capable of delegating to a common dialog service provided by your desktop.

  • Where possible, install applications through Flatpak or Snap. You’ll get the maximum amount of XDG Portal support by default, you won’t have to upgrade your whole distro to get access to new versions which add more portal support, and any testing the package maintainer does will be done with them enabled.
  • Anything using GtkFileDialog will use portals by default where available.
  • GtkFileChooserNative only uses portals when running under Flatpak/Snap by default, because of buggy behaviour in certain GNOME apps. However, if you’re not using those GNOME apps, you can set an environment variable named GDK_DEBUG=portals (formerly GTK_USE_PORTAL=1) to forcibly enable them.
  • Firefox/Thunderbird: If not using the official Flatpak or Snap packages, open up about:config and set widget.use-xdg-desktop-portal.file-picker to 1

Widgets and/or libadwaita

While I still think the need for it in this situation is a giant regression, I have to applaud the GTK developers for once again demonstrating that, regardless of my disagreements with them on what constitutes good UI design goals, their underlying infrastructure since the beginning of the GTK 3 era (GIR, gtk-rs, etc.) has been admirable.

As of GTK 3.14, they now have an equivalent to the Firefox Browser Toolbox that I pointed you at further up. It’s called GtkInspector, and it’s now a standard part of all GTK installs that just needs to be enabled through one of these means:

  • Run gsettings set org.gtk.Settings.Debug enable-inspector-keybinding true. Any GTK application started after you did that will open GtkInspector when you press Ctrl+Shift+D.

    (If it’s a Flatpak, you may need to use flatpak run --command='sh' <AppID> or flatpak enter <AppID> and run the gsettings command inside the Flatpak.)
  • Run the application with the GTK_DEBUG=interactive environment variable set. The inspector will open automatically.

Here are some tips:

  • GTK extends CSS with a @define-color name #c01040; construct, and those defined colours are referenced by using @name where you might otherwise use something like #f0f0f0 or white.
  • If your Flatpak app isn’t obeying the colours you expect and the widgets used by the application are very similar in Adwaita and your chosen theme, check the Visual tab in the inspector to see if it’s just falling back to Adwaita. See my previous comment about an open KDE bug for a workaround for that.
  • Look at the class name (eg. GtkPaned) in the Object tab’s header (to the right of the drop-down button) and search for it in the online GTK API documentation for whichever version of GTK you’re dealing with. Each entry has a “CSS nodes” section (intended to allow application developers to customize their UI) which will help you craft your overrides. (eg. GtkPaned under GTK 4)
  • Don’t get demoralized if your changes don’t seem to be doing anything. It is more finicky than tweaking Firefox’s UI using the Browser Toolbox.

To make changes to GTK 3 apps global and persistent, put the CSS you figure out into ~/config/.gtk-3.0/gtk.css. Here’s a fix I’m currently using:

/* Workaround for [Breeze] [Bug 414763] */
scrollbar trough { min-width: 6px; }
scrollbar:hover trough { min-width: 6px; }
scrollbar.horizontal trough { min-height: 6px; }
scrollbar.horizontal:hover.horizontal trough { min-height: 6px; }
scrollbar slider { min-width: 6px; }
scrollbar slider:hover { min-width: 6px; }
scrollbar.horizontal slider { min-height: 6px; }
scrollbar.horizontal slider { min-height: 6px; }

Fonts

As of GTK 4, lots of people without HiDPI displays have been complaining about blurry text. (i.e. the forcing of the “accurate glyph positioning is more important than crisp glyph edges” approach to low-resolution font rendering that Apple has been using since they stopped using bitmap fonts, long before high-DPI displays as opposed to the approach Microsoft has historically taken of using “font hinting” to find the least bad way to nudge lines to line up with pixel boundaries.)

None of the remaining GTK apps on my desktop have upgraded off GTK 3 yet (in fact, the Geeqie Flatpak finally considered their GTK 3 port debugged enough to migrate off GTK+ 2.x today) but I’ve read that making sure you’re on GTK 4.6 or newer and adding gtk-hint-font-metrics=1 to ~/.config/gtk-4.0/settings.ini will help.

See also the GTK page on Archwiki and, if you’re trying to harmonize GTK and Qt, the Uniform look for Qt and GTK applications too.

Ttk (Themed Tk)

Here’s a list of Ttk themes you can browse through to find something as close as possible to the rest of your desktop.

If their Installation guide isn’t enough, I wrote about how to to it more manually years ago.

Wine

Last time I tried using Wine’s .msstyle support (many years ago), it made the UI sluggish to respond, so I just found a .reg patch to apply the default Breeze colour scheme to regular Windows 9x-style Win32 widgets instead.

From what I remember, applications have to opt into themed widgets on Windows, while basic colour schemes go back at least as far as Windows 3.1, so you’d probably benefit from one of these even if you do enable a .msstyle theme… though the comments on the Breeze Dark colour scheme do point out that Wine 7.4 gained an on-by-default msstyle named “Light” that you may need to switch back to “(No style)” in winecfg.

Here’s what I used, plus a dark variant of it:

Web Apps

Tons of people have written about restyling things with CSS userstyles, so I’ll just give a few tips:

  • You can access Firefox’s normal context menu with Shift+RightClick if it’s been overridden.
  • You can access things like Page Info without knowing their keyboard shortcuts by tapping Alt to reveal the traditional menu bar.
  • I recommend Stylus as a userstyle host for Firefox and Ungoogled Chromium.
  • Here’s an example where I worked around Discord’s lack of easy-to-match CSS classes to turn off the distracting visual cacophony of customized username colours:
/* I don't want my chat client to look like a Hawaiian shirt, thanks. */
span[class^=roleColor-], span[class*=' roleColor-'] {
    color: #72767d !important;
}
span[class^=username-], span[class*=' username-'] {
    color: #23262a !important;
}

For the record, the ability to do this is one of the reasons I prefer in-browser versions of unavoidable web-tech to Electron versions. (The other major reason is that they’ll accept tighter sandboxing.)

Posted in Geek Stuff | Leave a comment