1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-15 23:59:45 +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); builtins.replaceStrings upperChars (map (c: "_${c}") lowerChars);
formatMonitor = monitor: desktops: formatMonitor = monitor: desktops:
let
resetDesktops =
"bspc monitor ${escapeShellArg monitor} -d ${escapeShellArgs desktops}"; "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: formatValue = v:
if isList v then if isList v then

View file

@ -185,6 +185,19 @@ in {
example = { "HDMI-0" = [ "web" "terminal" "III" "IV" ]; }; 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 { rules = mkOption {
type = types.attrsOf rule; type = types.attrsOf rule;
default = { }; default = { };

View file

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

View file

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