complete-computing-environment/declarative_kde_config.org

6.6 KiB
Raw Permalink Blame History

Declarative KDE Configuration with Home Manager

KDE configuration files are "INI-like" with some extra "magic" stuff built in like default values, environment dynamism, immutability… All of this is driven by a command called kwriteconfig5.

Generating kwriteconfig5 commands for home-manager to execute

In kurnevsky/nixfiles there is a simple module which generates a home-manager "writeBoundary" entry which will invoke kwriteconfig5 a bunch to write these INI files. This is a version of it which can be used throughout an Arroyo NixOS distribution.

I'm not sure if this will work if the switch happens while KDE is running, though…

{ config, pkgs, lib, ... }:

config: configs:
let 
  lines = lib.flatten (lib.mapAttrsToList (file: groups:
    lib.mapAttrsToList (group: keys:
      lib.mapAttrsToList (key: value:
        "test -f ~/.config/'${file}' && ${pkgs.libsForQt5.kconfig}/bin/kwriteconfig5 --file ~/.config/'${file}' --group '${group}' --key '${key}' '${toString value}'") keys) groups) configs);
in
config.lib.dag.entryAfter [ "writeBoundary" ]
  (builtins.concatStringsSep "\n" lines)

A simple invocation: specifying default KDE settings in home-manager attrsets

this can be invoked like so by feeding it a set shaped like [file,[group,[key, value]]], it only naively stringifys values so be careful. It's also available in Arroyo Nix lib/ as pkgs.lib.mkKwriteConfig5

{ pkgs, config, ... }:

let kconfig = pkgs.callPackage ../lib/kde-configs.nix {};
in {
  home.activation.krunnerConfig = pkgs.lib.mkKwriteConfig5 config {
    krunnerrc = {
      Plugins = {
        browserhistoryEnabled = "false";
        browsertabsEnabled = "false";
      };
    };
  };
  home.activation.kteatimeConfiguration = pkgs.lib.mkKwriteConfig5 config {
    kteatimerc = {
      Tealist = {
        "Tea0 Name" = "30s";
        "Tea0 Time" = "30";
        "Tea1 Name" = "45s";
        "Tea1 Time" = "45";
        "Tea2 Name" = "1m";
        "Tea2 Time" = "60";
        "Tea3 Name" = "1m30s";
        "Tea3 Time" = "90";
        "Tea4 Name" = "1m";
        "Tea4 Time" = "120";
      };
      General = {
        PopupAutoHide = "false";
        PopupAutoHideTime = 30;
        UsePopup = "true";
        UseReminder = "false";
        UseVisualize = "true";
      };
    };
  };
}

The values here are, unfortunately, pulled out of files in ~/.config which have been already configured in the GUI. It's easy enough to extract them once and never have to think about tweaking it again, and you're still able to overwrite the settings, but they won't apply until next login and will be overwritten the next time the home-manager profile is updated.

INPROGRESS declare your default/preferred desktop shortcuts in legible tables

  • State "INPROGRESS" from "NEXT" [2022-02-08 Tue 20:58]

I find it laudable but vexing when folks can use a computer with the default keyboard short cuts and "quality of life" configuration, or worse, swap between so many systems that no muscle memory is able to form. I don't have that, I want all my systems to behave similarly, and capturing my "default customizations" is a big part of the driving energy in The Complete Computing Environment, to capture my defaults and give hooks and patterns for others to do the same.

It is possible to generate these keyboard shortcuts tables, this is maybe too much Hypermedia metaprogramming though it's quite cool to be able to embed these legibly.

file group key value label
kglobalshortcutsrc kwin Switch to Desktop 1 Meta+1,Ctrl+F1 Switch to Desktop 1
kglobalshortcutsrc kwin Switch to Desktop 2 Meta+2,Ctrl+F2 Switch to Desktop 2
kglobalshortcutsrc kwin Switch to Desktop 3 Meta+3,Ctrl+F3 Switch to Desktop 3
kglobalshortcutsrc kwin Switch to Desktop 4 Meta+4,Ctrl+F4 Switch to Desktop 4
kglobalshortcutsrc kwin Switch to Desktop 5 Meta+5,Ctrl+F5 Switch to Desktop 5

Shortcuts get formatted in to Nix expressions with this awful format statement because the key is repeated in the value not sure why and I don't feel like digging in to explain it here. apply+apply-partially is fucking ugly, i'll write something better someday⋆.

(->> tbl
     (--map (apply (apply-partially #'format "%1$s.%2$s.\"%3$s\" = \"%4$s,%3$s\";") it))
     (s-join "\n"))
{ pkgs, config, ... }:


{
  home.activation.kconfigShortcuts = pkgs.lib.mkKwriteConfig5 config {
    <<shortcuts_str()>>
  };
}

WAITING integrate this with Bismuth Tiling Script

  • State "WAITING" from "NEXT" [2022-02-08 Tue 21:01]

It would be nice to set up a KDE + Wayland desktop with Bismuth tiling bindings "just working" and not colliding with KDE's defaults like I found in A report on krohnkite.

NEXT describe how to specify these

NEXT pull the rest of my default configuration tweaks out

NEXT commands for reloading apps with dbus?