modules/kwin: use more natural names

This commit is contained in:
Toast 2023-12-20 12:24:32 +01:00
parent 480ba1f95b
commit 6348923046

View File

@ -4,11 +4,54 @@ with lib;
let
cfg = config.programs.plasma;
validTitlebarButtons = {
longNames = [
"more-window-actions"
"application-menu"
"on-all-desktops"
"minimize"
"maximize"
"close"
"help"
"shade"
"keep-below-windows"
"keep-above-windows"
];
shortNames = [
"M"
"N"
"S"
"I"
"A"
"X"
"H"
"L"
"B"
"F"
];
};
# Gets a list with long names and turns it into short names
getShortNames = wantedButtons:
lists.forEach (
lists.flatten (
lists.forEach wantedButtons (currentButton:
lists.remove null (
lists.imap0 ( index: value:
if value == currentButton then "${toString index}" else null
) validTitlebarButtons.longNames
)
)
)
) getShortNameFromIndex;
# Gets the index and returns the short name in that position
getShortNameFromIndex = position: builtins.elemAt validTitlebarButtons.shortNames (strings.toInt position);
in
{
options.programs.plasma.kwin = {
titlebarButtons.right = mkOption {
type = with types; nullOr (listOf str);
type = with types; nullOr (listOf (enum validTitlebarButtons.longNames));
default = null;
example = [ "H" "I" "A" "X" ];
description = ''
@ -16,7 +59,7 @@ in
'';
};
titlebarButtons.left = mkOption {
type = with types; nullOr (listOf str);
type = with types; nullOr (listOf (enum validTitlebarButtons.longNames));
default = null;
example = [ "S" "F" ];
description = ''
@ -30,12 +73,12 @@ in
programs.plasma.configFile."kwinrc"."org\\.kde\\.kdecoration2" = mkMerge [
(
mkIf (cfg.kwin.titlebarButtons.left != null) {
"ButtonsOnLeft" = strings.concatStrings cfg.kwin.titlebarButtons.left;
"ButtonsOnLeft" = strings.concatStrings (getShortNames cfg.kwin.titlebarButtons.left);
}
)
(
mkIf (cfg.kwin.titlebarButtons.right != null) {
"ButtonsOnRight" = strings.concatStrings cfg.kwin.titlebarButtons.right;
"ButtonsOnRight" = strings.concatStrings (getShortNames cfg.kwin.titlebarButtons.right);
}
)
];