Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion modules/services/window-managers/bspwm/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions modules/services/window-managers/bspwm/options.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = { };
Expand Down
4 changes: 3 additions & 1 deletion tests/modules/services/window-managers/bspwm/bspwmrc
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down