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

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`.
This commit is contained in:
Naïm Favier 2022-03-18 03:56:56 +01:00 committed by GitHub
parent 32e433d07d
commit e2a85ac43f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 2 deletions

View file

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

View file

@ -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 = { };

View file

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

View file

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