There are some old questions similar to this; however, I haven't found a way to list and optionally close applications that are also minimized to system tray.
During a session log out in Windows, Windows gracefully asks all running GUI applications to gracefully terminate and only when all applications terminate normally and acknowledge this request Windows continues the log out process.
On the contrary, in Ubuntu, GNOME does not ask all applications to terminate gracefully, but just kill
s them during log out. There may be cases when you just don't notice that you have an editor open with unsaved data and in such a case you may lose all your updates. Or there may be some other GUI applications that need to be closed gracefully or have to continue running until some operation is finished.
For this reason, I created a script to find out all open GUI windows and then "gracefully" close them one by one. The key to this script is the command wmctrl -lp
for listing the applications and wmctrl -ic <win_id>
for sending a close message to an application whose window id is known. However, wmctrl -lp
fails to list any running applications that are minimized to system tray and thus have currently no window (and window id). Some sample applications that I use and can be minimized to system tray are: Viber (.deb package), Telegram (also .deb package) or some Wine (Windows) applications. Note that I am using the snap version of Firefox and wmctrl
successfully detects its window id, even though Firefox' parent seems to be systemd
.
I am currently using Xorg and prefer to continue using Xorg. But, I have tested with Wayland too and have seen worse results: in Wayland wmctrl -lp
fails to list most "normal" applications that are easily detected in Xorg.
Note: I have tested and I have seen that a minimized to tray application loses its window id. When restored (by interacting with the mouse on its icon on the system tray) it will get a new window id.
How can I get a list of all the minimized to tray applications and restore their windows so that I can manipulate them with wmctrl
?