[class=".*"] kill
this will run the i3 command kill
on every window. This includes the i3-bar, but as you are going to shut down anyway that should not be a problem.
You can just bind it to a shortcut:
bindsym Mod4+Mod1+q [class=".*"] kill
It is possible to chain the kill
command with the exit
command on the same shortcut. But I would advise against it, as kill
does not wait until the windows are gone before comming back and so i3 would likely exit before everything is closed. Especially if there are programs that ask for confirmation before closing ("Do you want to save before closing?").
Or you can use i3-nagbar
to ask whether i3 should close all windows or just exit:
bindsym Mod4+Mod1+q exec i3-nagbar -t warning -m 'Close all windows or exit?' -b 'Close all windows' 'i3-msg [class="^(!?.*i3bar).*$"] kill' -b 'Exit i3' 'i3-msg exit'
This provides two buttons, "Close all windows" and "Exit i3". The second one will exit i3, no further questions asked. The first one will run the aforementioned command with the small change class
criteria explicitly excludes the i3-bar. That way you can see on which workspace there are still open windows and take appropriate action. As the i3-nagbar stays open until explicitly closed (or until i3 exits) you can also repeatedly press "Close all windows".