Chaining Commands in herbstluftwm depending on the number of windows in the frame
0
votes
1
answer
220
views
I am wanting to configure window close behaviour so that, when I press the Mod+Shift+q. If the frame has one or no windows, close the window and remove the frame. If it has more than 1 window, only close the focused window. This makes it easier to close the frame/window dynamically depending on the windows in the frame.
I was able to solve the first part of the requirement by editing the config file as below. ie. if the frame has one or no windows close the window and removes the frame.
hc keybind $Mod-n and . compare tags.focus.curframe_wcount lt 2 . chain , close , remove
However, I am unable to chain the second part, where if the frame has more than 1 window, just close the focussed window. I tried below two options.
1. Tried chaining with an **or**
`hc keybind $Mod-n or | and . compare tags.focus.curframe_wcount lt 2 . chain , close ,
remove | close`
2. Tried writing a separate function
```
hc keybind $Mod-Shift-q close_frames
close_frames(){
WinCurFrame=$(hc attr tags.focus.curframe_wcount)
[[ WinInCurFrame < 2 ]] && hc close;remove || hc close
}
Asked by ThunderBolt
(1 rep)
Jul 24, 2021, 07:33 AM
Last activity: Jul 24, 2021, 07:46 PM
Last activity: Jul 24, 2021, 07:46 PM