1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-24 10:49:48 +01:00

bspwm: re-add support for lists as config option values (#2125)

Removed by mistake in e70524c, but ignore_ewmh_fullscreen still needs it.
This commit is contained in:
Naïm Favier 2021-06-20 06:57:40 +02:00 committed by GitHub
parent e70524cd2b
commit dc1b6b8349
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 31 deletions

View file

@ -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} &";

View file

@ -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 <literal>bspc config</literal>.";
example = {

View file

@ -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'

View file

@ -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;