project-repo / cagebreak

Cagebreak: A Wayland Tiling Compositor Inspired by Ratpoison
MIT License
273 stars 20 forks source link

Opening new window into empty space #41

Open mankeli opened 1 year ago

mankeli commented 1 year ago

Is it possible to open new window into already empty tile? It seems it currently always opens in the currently selected tile.

project-repo commented 1 year ago

Hi mankeli

What exactly do you mean? Would you like new windows to automatically open in an empty tile? What should happen if all tiles are already full?

Cheers project-repo

mankeli commented 1 year ago

My usecase is an emulator window and it's debugger in terminal.

With a stacking window manager, I launch the emulator from terminal window. The emulator's window opens somewhere on screen, and when i break to debugger I can just alt+tab to terminal window. Quit the emulator and repeat.

With cagebreak, the emulation window opens into same tile as console, then when I break to debugger, I need to split the tile which then puts emulator and terminal window next to each other. Then I can switch to the terminal tile and do my stuff there. If I now quit the emulator, there's an empty tile and need to use "only" command to remove the split. It's just a bunch of unnecessary keypresses.

Probably this could be solved by just having some kind of mechanism to select a tile where next window will be opened. Is it possible?

project-repo commented 1 year ago

I see - thanks for the clarification. Currently, there is no method in cagebreak to natively achieve such behaviour. You could try to use the socket to achieve what you are looking for.

I am thinking of a cagebreak keybinding which would run a skript doing the following:

Depending on how complex you want to make it you could also check that the "new window" and "close window" events come from the correct workspace, tile, pid etc. to make the workflow more robust.

Does that sound like something that would work for you? What do you think?

cheers project-repo

project-repo commented 1 year ago

Hi mankeli

Since this issue has not seen any activity for quite some time and since it does not concern a bug in Cagebreak, we are closing it for now. Feel free to reopen if you have any more information.

cheers project-repo

mankeli commented 4 months ago

Hi! Sorry for fading out last year, my laptop running this experimental setup with Cagebreak got smashed to ice and it took me a while to get a new setup!

So a bit refined idea: I think semantically tagging slots would be a nice feature. To kind of build workspaces. So if you open programs, they would go to specific slots automatically.

I wonder if you could provide a scripting example to send new windows with matching names to specific slots?

Also a bit outlandish idea maybe: While I've been configuring this thing, I've been thinking how awesome it would be to have lua script interpreter integrated in this, but maybe it could be done with just exec and the socket interface?

mankeli commented 4 months ago

@project-repo sorry I don't know if I have the power to re-open threads :thinking:

project-repo commented 4 months ago

Hi mankeli

We are currently discussing this internally but find the idea interesting.

We will reopen this for now.

cheers project-repo

project-repo commented 4 months ago

Hi mankeli

We considered your proposal and came up with a tentative implementation idea.

We would provide a command to move a view to a specific workspace.

syntax:

moveviewtoworkspace <view-id> <output> <workspace>

Using this command, you can write a script which listens for events indicating that a new view has been created and executes a moveviewtoworkspace command based on the title string and pid.

Because we expose almost everything over the socket as json, we don't feel like a native lua interpreter is needed. You are welcome to use lua, or any other language for that matter, to interact with the socket though.

cheers project-repo

mankeli commented 4 months ago

Does an empty workspace have 1 view, and once-splitted workspace has 2 views etc? With my proposal I meant that I'd like to be able to identify views and send windows into specific views within a workspace.

project-repo commented 4 months ago

Hi mankeli

Ah I see. No, the correct terminology is that a fullscreen workspace has 1 tile which can have a view (window) displayed within it. What you are planning to do requires a different command which we are also planning on implementing: moveviewtowtile <view-id> <tile-id> The procedure is then as described in the previous post. Does that make sense?

Cheers project-repo

mankeli commented 4 months ago

Ah, gotcha. Yes, I think that could enable automatic creation of those window (or view) ensembles I was thinking.

sodface commented 2 months ago

Because we expose almost everything over the socket as json, we don't feel like a native lua interpreter is needed. You are welcome to use lua, or any other language for that matter, to interact with the socket though.

At the risk of being slightly off-topic and annoying, I wanted to mention something I've been working on for my vehicle mounted touchscreen infotainment system, which is based mainly on Cagebreak and mpv. I wanted to simplify (and eliminate) the touchscreen gesture application I was using and realized that in addition to lua scripts, mpv supports c plugins so I wrote one based on libinput that works well for my needs.

Once I did that, I wrote another c plugin for interacting with the Cagebreak socket. Previously I'd done this with lua in mpv but moving the socket interaction to c made more sense to me. Since mpv provides an internal function for message passing between scripts (and c plugins), it's trivial to pass socket activity to a lua script and vice versa.

As I mentioned in another issue here, mpv also provides some utility functions for working with json, so there's no need (that I've found so far) for using jq or other solution for that.

If you use mpv in this role, you can start it via your Cagebreak config and pass multiple arguments to turn off features, like:

exec mpv --idle --load-scripts=no --video=no --audio=no --sub-ass=no --osc=no --config=no --load-osd-console=no --load-stats-overlay=no --ytdl=no --input-terminal=no --load-auto-profiles=no --script=$HOME/.config/cagebreak/cg-ipcc.so --script=$HOME/.config/cagebreak/cg-ipcl.lua --log-file=$HOME/mpv.log

This may be kind of a silly mis-use of mpv, but if you already have it installed, it might be worth considering.