kdotool icon indicating copy to clipboard operation
kdotool copied to clipboard

Multiple commands / stack manipulation

Open aditsu opened this issue 11 months ago • 4 comments

Hi, first of all, thank you for making kdotool.

I noticed that some commands can be chained, such as: kdotool getmouselocation getwindowname getwindowpid get_desktop_for_window However I can't find a way to do the same for a specific window id.

Also, the readme/help makes references to a "window stack" but doesn't explain what it is. Is it like stack-oriented programming, i.e. having a stack with window ids, and commands that operate on the top of the stack? In that case, is there a way to push/pop/duplicate(/etc) things on the stack? I'm thinking I could push a specific id and then call getwindowname getwindowpid...

Finally, let me know if there's a better place for support requests, I couldn't find anything.

aditsu avatar Jan 23 '25 07:01 aditsu

This tool tries to duplicate functionality of xdotool, so when unclear, you can refer to xdotool's documents.

I noticed that some commands can be chained, such as: kdotool getmouselocation getwindowname getwindowpid get_desktop_for_window However I can't find a way to do the same for a specific window id.

You can't do that at the moment. Also note that "window id" here is kwin's internal UUID. You can't use X11 window id.

Also, the readme/help makes references to a "window stack" but doesn't explain what it is. Is it like stack-oriented programming, i.e. having a stack with window ids, and commands that operate on the top of the stack?

No. It's just a list of windows. Just window managers organize windows as a stack, hence the name. See xdotool doc for details.

In that case, is there a way to push/pop/duplicate(/etc) things on the stack? I'm thinking I could push a specific id and then call getwindowname getwindowpid...

Not at the moment. But it would be trivial to add such commands.

Finally, let me know if there's a better place for support requests, I couldn't find anything.

AFAIK this is the only place for that.

jinliu avatar Jan 23 '25 13:01 jinliu

I'm not using X11 anything, only ids returned by "search". Whenever I say "window id", that's what I'm referring to. I think my problem would be solved if I could "search" for a specific window id, i.e. getting the stack to contain that id. Then I could chain commands for it.

aditsu avatar Jan 23 '25 13:01 aditsu

I would suggest making it possible to add/remove window_id to/from window stack.

Having such a feature would allow to compact this

# Minimize all but focused window
active_window_id=$(kdotool getactivewindow)
for window_id in $(kdotool search ".*")
do
    if [ $window_id != $active_window_id ]; then
        kdotool windowminimize $window_id
    fi
done

to something like this:

# Minimize all but focused window
kdotool windowminimize $(kdotool remove $(kdotool getactivewindow) $(kdotool search ".*"))

Going further it could be helpful to add/remove more than one window at once i.e. to be able to perform set operations on two window stacks.

piotr-dobrogost avatar Mar 26 '25 11:03 piotr-dobrogost

# Minimize all but focused window
kdotool windowminimize $(kdotool remove $(kdotool getactivewindow) $(kdotool search ".*"))

Going further it could be helpful to add/remove more than one window at once i.e. to be able to perform set operations on two window stacks.

This (add/remove from a list) can be done with shell's string list operations. So we only need a new command to replace the entire window stack with a new list of window IDs.

jinliu avatar Mar 27 '25 03:03 jinliu