diff --git a/modules/services/window-managers/bspwm/default.nix b/modules/services/window-managers/bspwm/default.nix index 9bcee08c2..c43be0740 100644 --- a/modules/services/window-managers/bspwm/default.nix +++ b/modules/services/window-managers/bspwm/default.nix @@ -10,39 +10,29 @@ let builtins.replaceStrings upperChars (map (c: "_${c}") lowerChars); formatMonitor = monitor: desktops: - "bspc monitor ${strings.escapeShellArg monitor} -d ${ - strings.escapeShellArgs desktops - }"; + "bspc monitor ${escapeShellArg monitor} -d ${escapeShellArgs desktops}"; - formatSetting = n: v: - let - vStr = if isBool v then - boolToString v - else if isInt v || isFloat v then - toString v - else if isString v then - strings.escapeShellArg v - else - throw "unsupported setting type for ${n}"; - in "bspc config ${strings.escapeShellArg n} ${vStr}"; + formatValue = v: + if isList v then + concatMapStringsSep "," formatValue v + else if isBool v then + if v then "on" else "off" + else if isInt v || isFloat v then + toString v + else if isString v then + v + else + throw "unsupported type"; # should not happen + + formatSetting = n: v: "bspc config ${escapeShellArgs [ n (formatValue v) ]}"; formatRule = target: directives: let - formatDirective = n: v: - let - vStr = if isBool v then - if v then "on" else "off" - else if isInt v || isFloat v then - toString v - else if isString v then - v - else - throw "unsupported rule attribute type for ${n}"; - in "${camelToSnake n}=${vStr}"; + formatDirective = n: v: "${camelToSnake n}=${formatValue v}"; - directivesStr = strings.escapeShellArgs (mapAttrsToList formatDirective + directivesStr = escapeShellArgs (mapAttrsToList formatDirective (filterAttrs (n: v: v != null) directives)); - in "bspc rule -a ${strings.escapeShellArg target} ${directivesStr}"; + in "bspc rule -a ${escapeShellArg target} ${directivesStr}"; formatStartupProgram = s: "${s} &"; diff --git a/modules/services/window-managers/bspwm/options.nix b/modules/services/window-managers/bspwm/options.nix index 8c5dc465a..25b209801 100644 --- a/modules/services/window-managers/bspwm/options.nix +++ b/modules/services/window-managers/bspwm/options.nix @@ -157,7 +157,7 @@ in { settings = mkOption { type = with types; let primitive = either bool (either int (either float str)); - in attrsOf primitive; + in attrsOf (either primitive (listOf primitive)); default = { }; description = "General settings given to bspc config."; example = { diff --git a/tests/modules/services/window-managers/bspwm/bspwmrc b/tests/modules/services/window-managers/bspwm/bspwmrc index 5430b2e1d..7ebb64aca 100755 --- a/tests/modules/services/window-managers/bspwm/bspwmrc +++ b/tests/modules/services/window-managers/bspwm/bspwmrc @@ -1,9 +1,10 @@ bspc monitor 'focused' -d 'desktop 1' 'd'\''esk top' -bspc config 'border_width' 2 +bspc config 'border_width' '2' bspc config 'external_rules_command' '/path/to/external rules command' -bspc config 'gapless_monocle' true -bspc config 'split_ratio' 0.520000 +bspc config 'gapless_monocle' 'on' +bspc config 'ignore_ewmh_fullscreen' 'enter,exit' +bspc config 'split_ratio' '0.520000' bspc rule -r '*' bspc rule -a '*' 'center=off' 'desktop=d'\''esk top#next' 'split_dir=north' 'sticky=on' diff --git a/tests/modules/services/window-managers/bspwm/configuration.nix b/tests/modules/services/window-managers/bspwm/configuration.nix index 3be3ced0f..6c1effb62 100644 --- a/tests/modules/services/window-managers/bspwm/configuration.nix +++ b/tests/modules/services/window-managers/bspwm/configuration.nix @@ -13,6 +13,7 @@ with lib; split_ratio = 0.52; gapless_monocle = true; external_rules_command = "/path/to/external rules command"; + ignore_ewmh_fullscreen = [ "enter" "exit" ]; }; rules."*" = { sticky = true;