[Solved]Modern Panel + Is there a close all option?

Questions about applications and software
Forum rules
Before you post please read how to get help
Post Reply
User avatar
CtrlAltDel
Level 5
Level 5
Posts: 522
Joined: Sun Jun 27, 2010 7:01 pm
Location: Birmingham, AL., USA

[Solved]Modern Panel + Is there a close all option?

Post by CtrlAltDel » Sat Jan 05, 2019 8:02 pm

I recently switched to the modern panel in Mint 19.1 and hope I may be overlooking the close all option in the right click context menu of open windows. Can someone confirm that the option to close all open windows in no longer available so I will know it's not just me.

Example:

Image

There is a close option but no close all.
Last edited by CtrlAltDel on Sun Jan 06, 2019 5:09 am, edited 1 time in total.
Intel i7-4790 Processor
Nvidia GeForce GT 720
8 GB Memory - 2x1 TB HD's
Mint 19.2 Cinnamon

User avatar
racer-x
Level 4
Level 4
Posts: 320
Joined: Sun Oct 02, 2016 9:05 am
Location: Area 51

Re: Modern Panel + Is there a close all option?

Post by racer-x » Sat Jan 05, 2019 8:36 pm

You can add a "Window List" applet to your panel. This will give the close all option.

Image

User avatar
CtrlAltDel
Level 5
Level 5
Posts: 522
Joined: Sun Jun 27, 2010 7:01 pm
Location: Birmingham, AL., USA

Re: Modern Panel + Is there a close all option?

Post by CtrlAltDel » Sat Jan 05, 2019 9:49 pm

You can add a "Window List" applet to your panel. This will give the close all option.
Thanks for the suggestion but, I think I'll pass on that. It's just duplicate copies of already open windows.
Intel i7-4790 Processor
Nvidia GeForce GT 720
8 GB Memory - 2x1 TB HD's
Mint 19.2 Cinnamon

User avatar
smurphos
Level 13
Level 13
Posts: 4804
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher
Contact:

Re: Modern Panel + Is there a close all option?

Post by smurphos » Sun Jan 06, 2019 4:15 am

With the grouped-window-list you only get close all and close others if you have grouping enabled, and have multiple windows in one group ( e.g. 2+ terminals open). The actions then only apply to the windows in that group.

I think this makes most sense in the context of a grouped window list.

I've added a couple of scripts to my system which I've set up to access as nemo actions (via right-click on the desktop) to 1) Close all windows in current workspace and 2) Close all windows in all workspaces. But you could also assign them to keyboard shortcuts, or make menu or panel launchers for them.

They close windows gracefully so if you've got an unsaved document etc that window will prompt you to save.

Both scripts require wmctrl to be installed - apt install wmctrl
The script that is per workspace only also requires xdotool - apt install xdotool
Save the scripts in ~/bin or ~/.local/bin and make them executable (right click > properties in the file manager). Suggested file names are in bold.

If these folders don't exist on your system create them. They are for user added scripts. You'll need to logout and log back in once created for them to be added to your $PATH.

The scripts...

close_all_windows_in_workspace.sh

Code: Select all

#!/bin/dash

# close all open windows in current workspace gracefully
# depends on xdotool (apt install xdotool) and wmctrl (apt install wmctrl)

# get current workspace with xdotool
WORKSPACE=$(xdotool get_desktop)

# get windows in current workspace
WINDOWS=$(wmctrl -l | awk "/ $WORKSPACE /" | cut -f1 -d' ')

# close windows gracefully
for i in $WINDOWS; do
    wmctrl -ic "$i"
done
close_all_windows.sh

Code: Select all

#!/bin/dash

# close all open windows gracefully
# depends on wmctrl (apt install wmctrl)

# get windows 
WINDOWS=$(wmctrl -l | cut -f1 -d' ')

# get ignored windows (desktop, conky etc)
NOTWINDOWS=$(wmctrl -l | awk "/ -1 /" | cut -f1 -d' ')

# close windows gracefully
for i in $WINDOWS; do
    if [ ! $(echo "$NOTWINDOWS" | grep -w "$i") ]; then
      wmctrl -ic "$i"
    fi
done
The nemo actions

These get saved in ~/.local/share/nemo/actions. They assume you named the scripts as suggested above.

close_all_windows_in_workspace.nemo_action

Code: Select all

[Nemo Action]
Name=Close all windows in workspace
Comment=Close all windows in current workspace
Exec=close_all_windows_in_workspace.sh
Selection=None
Extensions=any;
Icon-Name=application-exit-symbolic
Dependencies=xdotool;wmctrl;
Conditions=desktop;dbus org.Cinnamon;
close_all_windows.nemo_action

Code: Select all

[Nemo Action]
Name=Close all windows
Comment=Close all windows in all workspaces
Exec=close_all_windows.sh
Selection=None
Extensions=any;
Icon-Name=application-exit-symbolic
Dependencies=wmctrl;
Conditions=desktop;dbus org.Cinnamon;
Image
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.

User avatar
CtrlAltDel
Level 5
Level 5
Posts: 522
Joined: Sun Jun 27, 2010 7:01 pm
Location: Birmingham, AL., USA

Re: Modern Panel + Is there a close all option?

Post by CtrlAltDel » Sun Jan 06, 2019 5:01 am

smurphos wrote:
Sun Jan 06, 2019 4:15 am
I've added a couple of scripts to my system which I've set up to access as nemo actions (via right-click on the desktop) to 1) Close all windows in current workspace and 2) Close all windows in all workspaces. But you could also assign them to keyboard shortcuts, or make menu or panel launchers for them.
Fantastic! Thank you for taking all the time I know it took you to type out that post to help with this issue. I followed your directions and it works perfectly.
Intel i7-4790 Processor
Nvidia GeForce GT 720
8 GB Memory - 2x1 TB HD's
Mint 19.2 Cinnamon

Oblias
Level 1
Level 1
Posts: 39
Joined: Sat Jul 21, 2018 11:15 pm

Re: [Solved]Modern Panel + Is there a close all option?

Post by Oblias » Sun Jan 06, 2019 9:06 am

Fantastic script, thanks for sharing!! I do have a question, however @smurphos . Is there a way to have the script exclude one window that is open? I would like to have all open windows/programs closed except for Gkrellm when I run the script. Is this possible?

User avatar
smurphos
Level 13
Level 13
Posts: 4804
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher
Contact:

Re: [Solved]Modern Panel + Is there a close all option?

Post by smurphos » Sun Jan 06, 2019 9:11 am

Should be possible. What's the output of wmctrl -l with Gkrellm running?
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.

Oblias
Level 1
Level 1
Posts: 39
Joined: Sat Jul 21, 2018 11:15 pm

Re: [Solved]Modern Panel + Is there a close all option?

Post by Oblias » Sun Jan 06, 2019 9:16 am

The gkrellm line output is:

0x07000003 0 chaser-mint gkrellm


I should probably mention that I'm only using the close_all_windows_in_workspace.sh script..

User avatar
smurphos
Level 13
Level 13
Posts: 4804
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher
Contact:

Re: [Solved]Modern Panel + Is there a close all option?

Post by smurphos » Mon Jan 07, 2019 2:37 am

Here are versions of both scripts with an exclusion list with gkrellm excluded. The dummy foo entry is just to demonstrate for other readers how multiple excluded windows could be added. I suppose versions which are close all except current focused would be useful for some people as well....I feel a little project is coming on to make it a single multipurpose script - :)

close_all_windows_in_workspace.sh

Code: Select all

#!/bin/dash

# close all open windows in current workspace gracefully
# depends on xdotool (apt install xdotool) and wmctrl (apt install wmctrl)

# set any excluded windows
# add additional EXCLUSIONx lines as required
EXCLUSION1="foo"
EXCLUSION2="gkrellm"

# get current workspace with xdotool
WORKSPACE=$(xdotool get_desktop)

# get windows in current workspace
WINDOWS=$(wmctrl -l | awk "/ $WORKSPACE /" | cut -f1 -d' ')

# get ignored windows from exclusions
# expand awk statement with additional `|| /$EXCLUSIONx` as required
NOTWINDOWS=$(wmctrl -l | awk "/$EXCLUSION1/ || /$EXCLUSION2/" | cut -f1 -d' ')

# close windows gracefully
for i in $WINDOWS; do
  if [ ! $(echo "$NOTWINDOWS" | grep -w "$i") ]; then
    wmctrl -ic "$i"
  fi
  sleep 0.1
done
close_all_windows.sh

Code: Select all

#!/bin/dash

# close all open windows gracefully
# depends on wmctrl (apt install wmctrl)

# set any excluded windows
# add additional EXCLUSIONx lines as required
EXCLUSION1="foo"
EXCLUSION2="gkrellm"

# get windows 
WINDOWS=$(wmctrl -l | cut -f1 -d' ')

# get ignored windows from workspace -1 and exclusions
# expand awk statement with additional `|| /$EXCLUSIONx` as required
NOTWINDOWS=$(wmctrl -l | awk "/ -1 / || /$EXCLUSION1/ || /$EXCLUSION2/" | cut -f1 -d' ')

# close windows gracefully
for i in $WINDOWS; do
  if [ ! $(echo "$NOTWINDOWS" | grep -w "$i") ]; then
    wmctrl -ic "$i"
  fi
  sleep 0.1
done
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.

User avatar
CtrlAltDel
Level 5
Level 5
Posts: 522
Joined: Sun Jun 27, 2010 7:01 pm
Location: Birmingham, AL., USA

Re: [Solved]Modern Panel + Is there a close all option?

Post by CtrlAltDel » Mon Jan 07, 2019 2:51 am

smurphos wrote:
Mon Jan 07, 2019 2:37 am
I suppose versions which are close all except current focused would be useful for some people as well....I feel a little project is coming on to make it a single multipurpose script - :)

Yes, that would be great. :D
Intel i7-4790 Processor
Nvidia GeForce GT 720
8 GB Memory - 2x1 TB HD's
Mint 19.2 Cinnamon

Oblias
Level 1
Level 1
Posts: 39
Joined: Sat Jul 21, 2018 11:15 pm

Re: [Solved]Modern Panel + Is there a close all option?

Post by Oblias » Mon Jan 07, 2019 3:23 am

smurphos wrote:
Mon Jan 07, 2019 2:37 am
Here are versions of both scripts with an exclusion list with gkrellm excluded......................
Well done! I appreciate the effort you put into this, and will use it daily.

You may now go to your local pub and have one on me. Just tell the barkeep to put it on my tab! (But be sure to stand close to the door, just in case...) :wink:

Post Reply

Return to “Software & Applications”