baskerville / bspwm

A tiling window manager based on binary space partitioning
BSD 2-Clause "Simplified" License
7.61k stars 420 forks source link

Spawning a node on a certain desktop #1496

Open nikitarevenco opened 1 month ago

nikitarevenco commented 1 month ago

Hey, so I want to have kitty open with bpytop on desktop 9 everytime I start my computer (aka when bspwmrc loads.

This is one way to do it, but the problem is that you can see the window for a short period of time before it is sent over. And, sleeping an arbitrary amount of time doesn't feel right with me

kitty --class kitty -e bpytop &
sleep 0.2
kitty_window_id=$(bspc query -N -n .leaf.\!automatic.window.\!hidden.\!sticky | tail -n 1)
bspc node $kitty_window_id --to-desktop '^9'

Is there any way to create a node on a given desktop?

thelazt16 commented 1 month ago

Why not just create it with a distinguishable classname like kitty-bpytop and just add a rule for it to open it on desktop 9? I don't see the need of making a script for it.

bspc rule -a kitty-bpytop state=floating desktop='^9'

kitty --class kitty-bpytop -e bpytop &
nikitarevenco commented 1 month ago

Why not just create it with a distinguishable classname like kitty-bpytop and just add a rule for it to open it on desktop 9? I don't see the need of making a script for it.

bspc rule -a kitty-bpytop state=floating desktop='^9'

kitty --class kitty-bpytop -e bpytop &

Thank you for the response - But I should have also specified that I don't want to actually be sent to that desktop.Eg when my computer starts on desktop 1 kitty should be on desktop 9 but I should be on desktop 1

thelazt16 commented 1 month ago

Found the problem, it seems that kitty always want to have focus (it's a cat duh) and that's what cause spawing with kitty -e always focus you to that window. When I used alacritty instead of kitty it will spawn the program without sending the focus to that window

bspc rule -a kitty-bpytop state=floating desktop='^9'

alacritty --class kitty-bpytop -e bpytop &
thelazt16 commented 1 month ago

If you still want to use kitty you could set the rule for that class to hidden=on first, then once it spawned and sent to dektop 9, you can toggle the hidden flag.

#!/bin/bash
bspc rule -a kitty-btop hidden=on state=floating
kitty --class kitty-btop -e btop &
sleep 0.25
kitty_window_id=$(xdotool search --class kitty-btop)
bspc node "$kitty_window_id" --to-desktop '^9' --flag hidden

The sleep time should consider when the program fully loaded. 0.25 is the lowest I checked, otherwise kitty will take focus.