Add titleReplacements option for application-title-bar (#260)

This commit is contained in:
Heitor Augusto 2024-07-13 15:46:53 -03:00 committed by GitHub
parent 40fa15ecee
commit 18ae86b008
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -83,6 +83,30 @@ let
};
};
};
titleReplacementType = types.submodule {
options = {
type =
let enumVals = [ "string" "regexp" ];
in mkOption {
type = types.enum enumVals;
default = null;
example = "string";
description = "The type of the replacement.";
apply = getIndexFromEnum enumVals;
};
originalTitle = mkOption {
type = types.str;
example = "Brave Web Browser";
description = "The original text to replace.";
};
newTitle = mkOption {
type = types.str;
example = "Brave";
description = "The new text to replace with.";
};
};
};
in
{
applicationTitleBar = {
@ -391,6 +415,28 @@ in
description = "The action to perform on wheel right.";
};
};
titleReplacements = mkOption {
type = with types; nullOr (listOf titleReplacementType);
default = null;
example = [
{
type = "string";
originalTitle = "Brave Web Browser";
newTitle = "Brave";
}
{
type = "regexp";
originalTitle = ''\\bDolphin\\b'';
newTitle = "File manager";
}
];
description = "The replacements for the window title.";
apply = replacements: lib.optionalAttrs (replacements != null) {
titleReplacementsPatterns = map (r: r.originalTitle) replacements;
titleReplacementsTemplates = map (r: r.newTitle) replacements;
titleReplacementsTypes = map (r: r.type) replacements;
};
};
};
convert =
{ layout
@ -401,6 +447,7 @@ in
, mouseAreaDrag
, mouseAreaClick
, mouseAreaWheel
, titleReplacements
}: {
name = "com.github.antroids.application-title-bar";
config = {
@ -473,6 +520,7 @@ in
widgetMouseAreaWheelRightAction = mouseAreaWheel.wheelRight;
}
);
TitleReplacements = titleReplacements;
};
};
};