You are not logged in.
I was wondering if anyone knew of a way to setup a hotkey that would close all windows at the same time?
XWM only has a hotkey that allows one window to be closed at a time.
I was not sure if maybe there was a hidden way to achieve this?
Imagine this would require some kind of Bash script?
Would be for all programs "window buttons" opened in panel, I guess in current workspace?
Not sure if there are more specific ways?
-Only current Workspace
-All programs opened in all Workspaces
Thank You
Last edited by advice1010 (2025-08-16 17:16:02)
Offline
You can use the following script (it requires wmctrl). Make it executable and assign it to keyboard shortcuts:
Keyboard Shortcut #1: Close all windows
/path/to/script all
Keyboard Shortcut #2: Close only windows on current workspace
/path/to/script current
Script
#!/usr/bin/env bash
# script to close windows
# requires: wmctrl
# parameters: all = all open windows
# current = only on current workspace
case $1 in
all)
for w in $(wmctrl -lv | grep -v " -1 " | awk '{print $1}')
do
wmctrl -ic $w
done
;;
current)
CURRENT=$(wmctrl -d | grep "*" | awk '{print $1}')
for w in $(wmctrl -lv | grep -v " -1 " | grep " $CURRENT " | awk '{print $1}')
do
wmctrl -ic $w
done
;;
*)
echo "You need to specify either "all" (to close all windows) or "current" to close only the windows on the current workspace."
;;
esac
exit 0
Note that the "wmctrl -ic" command will try to gracefully close windows - not force close them.
Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline
@ToZ
Thank you so much for providing this script.
I was not able to test the Workspace part yet because I am still working on Workspace setup, but was able to test the ALL version, which works great.
I am really glad I asked for two things in this case.
I do not think I have ever seen a Bash script that had the capability of using options when running the script like this.
I generally have only seen options within the Bash script files. Did not even know this was possible, wow thank you also for bringing this to my attention
Offline
[ Generated in 0.012 seconds, 7 queries executed - Memory usage: 535.68 KiB (Peak: 536.96 KiB) ]