Open verajosemanuel opened 3 years ago
You can use external rules.
Example1 (apply the rule only if the number of windows in the first desktop is less than 3):
#!/bin/sh
class=$2
if [ "$class" = URxvt ]; then
if [ "$(bspc query -N -d '^1' -n .window | wc -l)" -lt 3 ]
then echo 'desktop=^1 follow=on focus=on'
fi
fi
Example2 (apply the rule only if the number of terminal windows in the first desktop is less than 3):
#!/bin/sh
class=$2
if [ "$class" = URxvt ]; then
same_class_windows_count=$(
bspc query -N -d '^1' -n .window \
| while IFS= read -r w; do
xdo id -N "$class" "$w"
done \
| wc -l
)
if [ "$same_class_windows_count" -lt 3 ]
then echo 'desktop=^1 follow=on focus=on'
fi
fi
Replace URxvt
with your terminal's class name.
To use external rules, run bspc config external_rules_command /full/path/to/external_rules_script
(put it in bspwmrc
) and make sure that the script is executable.
The external_rules_command
is run by bspwm
before it manages a window; it can be any program written in any programming language.
It receive 4 arguments:
$1
the X window id of the new window;$2
the class name of the new window;$3
the instance name of the new window;$4
an sh
eval
-friendly string that represents the rule "consequences" that have already been applied by regular rules e.g. state=floating hidden=on
. Its output should use the same syntax of regular rules: e.g. state=fullscreen
, sticky=on
, &c and is applied as a final rule before the window finally gets managed.
Great explanation!!!
I work mainly using terminal. On my Fresh vanilla install of archcraft terminals are assigned to WS one. Browser to WS and so on.... My issue is when opening more than three terminals , there’s not enough room for all of them in WS one. So I focus WS 5 and open a terminal but it always ended on WS one.
I know this can be suppressed commenting the proper lines in config but I like the assignment so my question is:
is there any way of limiting the number of windows per WS?
maybe
3 for WS 1 : terminals 2 for browsers at WS 2....and so on