From 3066cc58f552421a2c5414e78407fa5603405b1e Mon Sep 17 00:00:00 2001 From: Matthieu Coudron <886074+teto@users.noreply.github.com> Date: Thu, 12 Dec 2024 23:48:46 +0100 Subject: [PATCH] kanshi: dont write config in absence of nix settings (#6198) --- modules/services/kanshi.nix | 16 ++++++++-------- .../services/kanshi/new-configuration.conf | 1 - 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/modules/services/kanshi.nix b/modules/services/kanshi.nix index 2eda74876..808966282 100644 --- a/modules/services/kanshi.nix +++ b/modules/services/kanshi.nix @@ -38,9 +38,7 @@ let else throw "Unknown tags ${attrNames x}"; - directivesStr = '' - ${concatStringsSep "\n" (map tagToStr cfg.settings)} - ''; + directivesStr = concatStringsSep "\n" (map tagToStr cfg.settings); oldDirectivesStr = '' ${concatStringsSep "\n" @@ -332,11 +330,13 @@ in { { home.packages = [ cfg.package ]; - xdg.configFile."kanshi/config".text = - if cfg.profiles == { } && cfg.extraConfig == "" then - directivesStr - else - oldDirectivesStr; + xdg.configFile."kanshi/config" = let + generatedConfigStr = + if cfg.profiles == { } && cfg.extraConfig == "" then + directivesStr + else + oldDirectivesStr; + in mkIf (generatedConfigStr != "") { text = generatedConfigStr; }; systemd.user.services.kanshi = { Unit = { diff --git a/tests/modules/services/kanshi/new-configuration.conf b/tests/modules/services/kanshi/new-configuration.conf index 817f66329..5a11a5283 100644 --- a/tests/modules/services/kanshi/new-configuration.conf +++ b/tests/modules/services/kanshi/new-configuration.conf @@ -16,4 +16,3 @@ profile { output "LVDS-1" enable exec echo "7 eight 9" } -