Skip to content

Commit

Permalink
Generate konsole profiles using generators.toINI
Browse files Browse the repository at this point in the history
  • Loading branch information
toast003 committed Mar 3, 2024
1 parent da0a65b commit 095d7b6
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions modules/apps/konsole.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ with lib;
let
cfg = config.programs.konsole;
profilesSubmodule = {
# TODO: don't set null as the defaults, toINI doesn't like it
options = {
name = mkOption {
type = with types; nullOr str;
Expand Down Expand Up @@ -126,29 +127,30 @@ in
)
];

programs.plasma.dataFile = mkIf (cfg.profiles != {}) (
xdg.dataFile = mkIf (cfg.profiles != {}) (
mkMerge ([
(
mkMerge (
mapAttrsToList (
attrName: profile:
let
# Use the name from the name option if it's set
profileName = if builtins.isString profile.name then profile.name else attrName;
profileName = if builtins.isString profile.name then profile.name else attrName;
fontString = mkIf (profile.font.name != null) "${profile.font.name},${builtins.toString profile.font.size}";
in
{
"konsole/${profileName}.profile" = {
"konsole/${profileName}.profile".text = lib.generators.toINI {} {
"General" = {
"Command" = profile.command;
"Command" = (mkIf (profile.command != null) profile.command).content;
"Name" = profileName;
# Konsole generated profiles seem to allways have this
"Parent" = "FALLBACK/";
};
"Appearance" = {
"ColorScheme" = profile.colorScheme;
"ColorScheme" = (mkIf (profile.colorScheme != null) profile.colorScheme).content;
# If the font size is not set we leave a comma a the end after the name
# We should fix this probs but konsole doesn't seem to care ¯\_(ツ)_/¯
"Font" = with profile.font; "${name},${builtins.toString size}";
"Font" = fontString.content;
};
};
}
Expand Down

0 comments on commit 095d7b6

Please sign in to comment.