this script was taken from askubuntu and official manjaro forum.
This is great to close all windows opened but at the same time all you dont..
first check all windows you dont intend to be closed doing this in terminal
wmctrl -l
if you dont have wmctrl installed you can pick up on pkgs.org
edit the script and change cinnamon-panel by your desktop panel name
add either the intended window to not be closed as for example of mine ... Docky
you can put on panel as command launcher
DOWNLOAD script
https://drive.google.com/open?id=18tWjJ ... a4D-0dSXul
DOWNLOAD panel icon
https://drive.google.com/open?id=1LM_U3 ... 8cL6hL3qoC
Close all Windows at Once
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Topics in this forum are automatically closed 6 months after creation.
Close all Windows at Once
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: Close all Windows at Once
Instead of filtering with app name you could filter out X window properties.
This asks to close gracefully only normal windows and dialogs.
Conky, Docky xfce and other stuff should be safe in theory.
Anyhow, I have a hunch that @Xenopeek probably has a better way to do this.
This asks to close gracefully only normal windows and dialogs.
Conky, Docky xfce and other stuff should be safe in theory.
Code: Select all
#!/bin/bash
#Check dependancies
DEPCOUNT=0
for DEP in /usr/bin/{zenity,xprop,wmctrl,awk} /bin/{grep,echo}; {
[ -x "$DEP" ] || {
echo "$LINENO" "Dependency '$DEP' not met."
DEPCOUNT+=1
}
}
[ $DEPCOUNT -gt 0 ] && exit 1
# With process substitution output from "wmctrl -l" is redirected to file descriptor 3
# while loop reads "win_id" and "display" variables from file descriptor 3
while read -r win_id display text <&3
do
# filter windows with win_id that has X window properties of type normal or dialog
if xprop -id $win_id | grep -e "^_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_NORMAL" \
-e "^_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_DIALOG" &>/dev/null
then
# Get WM_CLASS X window property
wm_class=$(xprop -id $win_id WM_CLASS | awk -F'"' '{print $4}')
# if WM_CLASS is a "Wrapper"
if [[ "${wm_class}" == "Wrapper" ]]
then
# Get WM_CLASS X window property _NET_WM_NAME
wm_class=$(xprop -id $win_id _NET_WM_NAME | awk -F '"' '{print $2}')
echo "#Closing: $wm_class $text" $"\n ID: $win_id on display :$display"
else
echo "#Closing: $wm_class $text" $"\nID: $win_id on display :$display"
fi
# Gracefully ask for close
wmctrl -ic "$win_id"
sleep 2
fi
done 3< <(wmctrl -l -x | awk '{print $1,$2,substr($0, index($0,$4), 32)}') | zenity --progress --pulsate --auto-close
# Close file descriptor 3
exec 3<&-
exit