bspwm: add alwaysResetDesktops (#2785)

If set to true, desktops configured in `monitors` will be reset every time
the config is run.

If set to false, desktops will only be configured the first time the config is run.
This is useful if you want to dynamically add desktops and you don't want them
to be destroyed if you re-run `bspwmrc`.
main
Naïm Favier 2 years ago committed by GitHub
parent 32e433d07d
commit e2a85ac43f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      modules/services/window-managers/bspwm/default.nix
  2. 13
      modules/services/window-managers/bspwm/options.nix
  3. 4
      tests/modules/services/window-managers/bspwm/bspwmrc
  4. 1
      tests/modules/services/window-managers/bspwm/configuration.nix

@ -10,7 +10,19 @@ let
builtins.replaceStrings upperChars (map (c: "_${c}") lowerChars);
formatMonitor = monitor: desktops:
"bspc monitor ${escapeShellArg monitor} -d ${escapeShellArgs desktops}";
let
resetDesktops =
"bspc monitor ${escapeShellArg monitor} -d ${escapeShellArgs desktops}";
defaultDesktopName =
"Desktop"; # https://github.com/baskerville/bspwm/blob/master/src/desktop.h
in if cfg.alwaysResetDesktops then
resetDesktops
else ''
if [[ $(bspc query --desktops --names --monitor ${
escapeShellArg monitor
}) == ${defaultDesktopName} ]]; then
${resetDesktops}
fi'';
formatValue = v:
if isList v then

@ -185,6 +185,19 @@ in {
example = { "HDMI-0" = [ "web" "terminal" "III" "IV" ]; };
};
alwaysResetDesktops = mkOption {
type = types.bool;
default = true;
description = ''
If set to <literal>true</literal>, desktops configured in <option>monitors</option> will be reset
every time the config is run.
If set to <literal>false</literal>, desktops will only be configured the first time the config is run.
This is useful if you want to dynamically add desktops and you don't want them to be destroyed if you
re-run <literal>bspwmrc</literal>.
'';
};
rules = mkOption {
type = types.attrsOf rule;
default = { };

@ -1,4 +1,6 @@
bspc monitor 'focused' -d 'desktop 1' 'd'\''esk top'
if [[ $(bspc query --desktops --names --monitor 'focused') == Desktop ]]; then
bspc monitor 'focused' -d 'desktop 1' 'd'\''esk top'
fi
bspc config 'border_width' '2'
bspc config 'external_rules_command' '/path/to/external rules command'

@ -8,6 +8,7 @@ with lib;
enable = true;
monitors.focused =
[ "desktop 1" "d'esk top" ]; # pathological desktop names
alwaysResetDesktops = false;
settings = {
border_width = 2;
split_ratio = 0.52;

Loading…
Cancel
Save