complete-computing-environment/declarative_kde_config.org

145 lines
6.6 KiB
Org Mode

:PROPERTIES:
:ID: cce/declarative-kconfig
:ROAM_ALIASES: "Declarative KDE Shortcuts" "declarative kwriteconfig5"
:END:
#+TITLE: Declarative KDE Configuration with Home Manager
#+filetags: :CCE:KDE:Development:
#+ARCOLOGY_KEY: cce/declarative-kwriteconfig5
[[https://userbase.kde.org/KDE_System_Administration/Configuration_Files][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 [[id:cce/home-manager][home-manager]] to execute
:PROPERTIES:
:ID: 20220208T202521.986929
:END:
In [[https://github.com/kurnevsky/nixfiles/blob/master/modules/kde.nix#L94][kurnevsky/nixfiles]] there is a simple module which generates a [[id:cce/home-manager][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 [[id:arroyo/nixos][Arroyo NixOS]] distribution.
I'm not sure if this will work if the switch happens while KDE is running, though...
#+begin_src nix :tangle ~/arroyo-nix/lib/kde-configs.nix
{ 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)
#+end_src
* A simple invocation: specifying default KDE settings in =home-manager= attrsets
:PROPERTIES:
:ID: 20220208T202524.889588
:END:
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 [[id:20221021T115008.329657][Arroyo Nix]] =lib/= as =pkgs.lib.mkKwriteConfig5=
#+ARROYO_HOME_MODULE: hm/kde-config-basics.nix
#+ARROYO_SYSTEM_ROLE: endpoint
#+begin_src nix :tangle ~/arroyo-nix/hm/kde-config-basics.nix :noweb yes
{ 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";
};
};
};
}
#+end_src
The values here are, unfortunately, pulled out of files in [[file:~/.config][~/.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 [[id:cce/home-manager][home-manager]] profile is updated.
* INPROGRESS declare your default/preferred desktop shortcuts in legible tables
:PROPERTIES:
:ID: 20220517T150556.220165
:END:
:LOGBOOK:
- State "INPROGRESS" from "NEXT" [2022-02-08 Tue 20:58]
:END:
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 [[id:cce/cce][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 [[id:128ab0e8-a1c7-48bf-9efe-0c23ce906a48][Hypermedia metaprogramming]] though it's quite cool to be able to embed these legibly.
#+name: shortcuts_tbl
| 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⋆.
#+name: shortcuts_str
#+begin_src emacs-lisp :var tbl=shortcuts_tbl :exports code
(->> tbl
(--map (apply (apply-partially #'format "%1$s.%2$s.\"%3$s\" = \"%4$s,%3$s\";") it))
(s-join "\n"))
#+end_src
#+results: shortcuts_str
: 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";
#+begin_src nix :tangle ~/arroyo-nix/hm/kde-config-shortcuts.nix :noweb tangle
{ pkgs, config, ... }:
{
home.activation.kconfigShortcuts = pkgs.lib.mkKwriteConfig5 config {
<<shortcuts_str()>>
};
}
#+end_src
** WAITING integrate this with [[id:20220208T151221.985071][Bismuth Tiling Script]]
:LOGBOOK:
- State "WAITING" from "NEXT" [2022-02-08 Tue 21:01]
:END:
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 [[id:20220208T210931.535051][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?