How to quickly minimize all windows for a single application?












3














I know how to minimize/hide all windows in Cosmic Cuttlefish/GNOME Shell using SUPER+D, but I would like to be able to quickly minimize only all windows for a single application (say the one that currently has cursor focus). For example, I would like to minimize all LibreOffice documents, or all Terminal windows.



I am not quite seeing or recognizing a way to do this in Settings > Devices > Keyboard. Is this possible?










share|improve this question









New contributor




Lexible is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    3














    I know how to minimize/hide all windows in Cosmic Cuttlefish/GNOME Shell using SUPER+D, but I would like to be able to quickly minimize only all windows for a single application (say the one that currently has cursor focus). For example, I would like to minimize all LibreOffice documents, or all Terminal windows.



    I am not quite seeing or recognizing a way to do this in Settings > Devices > Keyboard. Is this possible?










    share|improve this question









    New contributor




    Lexible is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      3












      3








      3


      1





      I know how to minimize/hide all windows in Cosmic Cuttlefish/GNOME Shell using SUPER+D, but I would like to be able to quickly minimize only all windows for a single application (say the one that currently has cursor focus). For example, I would like to minimize all LibreOffice documents, or all Terminal windows.



      I am not quite seeing or recognizing a way to do this in Settings > Devices > Keyboard. Is this possible?










      share|improve this question









      New contributor




      Lexible is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      I know how to minimize/hide all windows in Cosmic Cuttlefish/GNOME Shell using SUPER+D, but I would like to be able to quickly minimize only all windows for a single application (say the one that currently has cursor focus). For example, I would like to minimize all LibreOffice documents, or all Terminal windows.



      I am not quite seeing or recognizing a way to do this in Settings > Devices > Keyboard. Is this possible?







      shortcut-keys gnome-shell shortcuts






      share|improve this question









      New contributor




      Lexible is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      Lexible is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited yesterday









      pomsky

      29k1189115




      29k1189115






      New contributor




      Lexible is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked yesterday









      LexibleLexible

      1214




      1214




      New contributor




      Lexible is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Lexible is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Lexible is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          2 Answers
          2






          active

          oldest

          votes


















          6














          OK, just a quick one for fun :)



          Minimize windows of currently active application



          You could use a stripped-down/edited version of this script, which comes with a default Ubuntu Budgie install.
          While the original script toggles the desktop, the edited one below minimizes all windows, on current workspace, of the currently active WM_CLASS.



          The script, how to use





          • Make sure you have both xdotool and wmctrl installed:



            sudo apt install wmctrl xdotool


          • Copy the script below into an empty file, save it as minimize_current.py


          • Create a keyboard shortcut to run the script and you're done :). Use the command:



            python3 /path/to/minimize_current.py



          The script



          #!/usr/bin/env python3
          import subprocess

          ignore = [
          "= _NET_WM_WINDOW_TYPE_DOCK",
          "= _NET_WM_WINDOW_TYPE_DESKTOP",
          ]


          def get(cmd):
          return subprocess.check_output(cmd).decode("utf-8").strip()


          def get_currws():
          return [l.split()[0] for l in get(
          ["wmctrl", "-d"]).splitlines() if "*" in l][0]


          def get_valid(w_id):
          # see if the window is a valid one (type)
          w_data = get(["xprop", "-id", w_id])
          if w_data:
          return True if not any([t in w_data for t in ignore]) else False
          else:
          return False

          def get_wmclass(w_id):
          return get(["xprop", "-id", w_id, "WM_CLASS"])


          def get_state(w_id):
          return "window state: Iconic" in get(["xprop", "-id", w_id, "WM_STATE"])


          currws = get_currws()
          allwinsdata = [w.split() for w in get(["wmctrl", "-l"]).splitlines()]
          winsoncurr = [w[0] for w in allwinsdata if w[1] == currws]

          active_w = get(["xdotool", "getactivewindow"])
          activeclass = get_wmclass(active_w)
          relevant = [w for w in winsoncurr if get_valid(w)]


          # windows on current workspace, normal state
          tominimize = [
          w for w in relevant if all(
          [not get_state(w), get_wmclass(w) == activeclass]
          )
          ]

          if tominimize:
          for w in tominimize:
          subprocess.Popen(["xdotool", "windowminimize", w])





          share|improve this answer



















          • 2




            Since this uses xdotool this only works when using X-server and not with Wayland, right?
            – Graipher
            19 hours ago






          • 2




            @Graipher That is correct. Xdotool nor wmctrl will work on Wayland.
            – Jacob Vlijm
            19 hours ago



















          6














          This is not a keyboard shortcut, but another way to minimise all windows of an application. You can enable 'minimise on click' in Ubuntu dock. Then once you click an application icon in the dock, it would minimise all windows (or raise, if they're already minimised) of that application.



          To enable this option, run the following command in Terminal:



          gsettings set org.gnome.shell.extensions.dash-to-dock click-action 'minimize'


          (Reference: How do I enable 'minimize on click' on Ubuntu dock in Ubuntu 17.10 and later?)






          share|improve this answer























          • That is really useful to know, thank you! +1 I am gonna decline to accept this answer for the time being, both because "too soon" and because others may have a keyboard shortcut solution. This answer is definitely in the running though. :)
            – Lexible
            yesterday








          • 1




            @Lexible Sure, I would recommend not accepting too :) For the same reason I didn't vote to close as a duplicate of the other question.
            – pomsky
            yesterday











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "89"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          Lexible is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1107496%2fhow-to-quickly-minimize-all-windows-for-a-single-application%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          6














          OK, just a quick one for fun :)



          Minimize windows of currently active application



          You could use a stripped-down/edited version of this script, which comes with a default Ubuntu Budgie install.
          While the original script toggles the desktop, the edited one below minimizes all windows, on current workspace, of the currently active WM_CLASS.



          The script, how to use





          • Make sure you have both xdotool and wmctrl installed:



            sudo apt install wmctrl xdotool


          • Copy the script below into an empty file, save it as minimize_current.py


          • Create a keyboard shortcut to run the script and you're done :). Use the command:



            python3 /path/to/minimize_current.py



          The script



          #!/usr/bin/env python3
          import subprocess

          ignore = [
          "= _NET_WM_WINDOW_TYPE_DOCK",
          "= _NET_WM_WINDOW_TYPE_DESKTOP",
          ]


          def get(cmd):
          return subprocess.check_output(cmd).decode("utf-8").strip()


          def get_currws():
          return [l.split()[0] for l in get(
          ["wmctrl", "-d"]).splitlines() if "*" in l][0]


          def get_valid(w_id):
          # see if the window is a valid one (type)
          w_data = get(["xprop", "-id", w_id])
          if w_data:
          return True if not any([t in w_data for t in ignore]) else False
          else:
          return False

          def get_wmclass(w_id):
          return get(["xprop", "-id", w_id, "WM_CLASS"])


          def get_state(w_id):
          return "window state: Iconic" in get(["xprop", "-id", w_id, "WM_STATE"])


          currws = get_currws()
          allwinsdata = [w.split() for w in get(["wmctrl", "-l"]).splitlines()]
          winsoncurr = [w[0] for w in allwinsdata if w[1] == currws]

          active_w = get(["xdotool", "getactivewindow"])
          activeclass = get_wmclass(active_w)
          relevant = [w for w in winsoncurr if get_valid(w)]


          # windows on current workspace, normal state
          tominimize = [
          w for w in relevant if all(
          [not get_state(w), get_wmclass(w) == activeclass]
          )
          ]

          if tominimize:
          for w in tominimize:
          subprocess.Popen(["xdotool", "windowminimize", w])





          share|improve this answer



















          • 2




            Since this uses xdotool this only works when using X-server and not with Wayland, right?
            – Graipher
            19 hours ago






          • 2




            @Graipher That is correct. Xdotool nor wmctrl will work on Wayland.
            – Jacob Vlijm
            19 hours ago
















          6














          OK, just a quick one for fun :)



          Minimize windows of currently active application



          You could use a stripped-down/edited version of this script, which comes with a default Ubuntu Budgie install.
          While the original script toggles the desktop, the edited one below minimizes all windows, on current workspace, of the currently active WM_CLASS.



          The script, how to use





          • Make sure you have both xdotool and wmctrl installed:



            sudo apt install wmctrl xdotool


          • Copy the script below into an empty file, save it as minimize_current.py


          • Create a keyboard shortcut to run the script and you're done :). Use the command:



            python3 /path/to/minimize_current.py



          The script



          #!/usr/bin/env python3
          import subprocess

          ignore = [
          "= _NET_WM_WINDOW_TYPE_DOCK",
          "= _NET_WM_WINDOW_TYPE_DESKTOP",
          ]


          def get(cmd):
          return subprocess.check_output(cmd).decode("utf-8").strip()


          def get_currws():
          return [l.split()[0] for l in get(
          ["wmctrl", "-d"]).splitlines() if "*" in l][0]


          def get_valid(w_id):
          # see if the window is a valid one (type)
          w_data = get(["xprop", "-id", w_id])
          if w_data:
          return True if not any([t in w_data for t in ignore]) else False
          else:
          return False

          def get_wmclass(w_id):
          return get(["xprop", "-id", w_id, "WM_CLASS"])


          def get_state(w_id):
          return "window state: Iconic" in get(["xprop", "-id", w_id, "WM_STATE"])


          currws = get_currws()
          allwinsdata = [w.split() for w in get(["wmctrl", "-l"]).splitlines()]
          winsoncurr = [w[0] for w in allwinsdata if w[1] == currws]

          active_w = get(["xdotool", "getactivewindow"])
          activeclass = get_wmclass(active_w)
          relevant = [w for w in winsoncurr if get_valid(w)]


          # windows on current workspace, normal state
          tominimize = [
          w for w in relevant if all(
          [not get_state(w), get_wmclass(w) == activeclass]
          )
          ]

          if tominimize:
          for w in tominimize:
          subprocess.Popen(["xdotool", "windowminimize", w])





          share|improve this answer



















          • 2




            Since this uses xdotool this only works when using X-server and not with Wayland, right?
            – Graipher
            19 hours ago






          • 2




            @Graipher That is correct. Xdotool nor wmctrl will work on Wayland.
            – Jacob Vlijm
            19 hours ago














          6












          6








          6






          OK, just a quick one for fun :)



          Minimize windows of currently active application



          You could use a stripped-down/edited version of this script, which comes with a default Ubuntu Budgie install.
          While the original script toggles the desktop, the edited one below minimizes all windows, on current workspace, of the currently active WM_CLASS.



          The script, how to use





          • Make sure you have both xdotool and wmctrl installed:



            sudo apt install wmctrl xdotool


          • Copy the script below into an empty file, save it as minimize_current.py


          • Create a keyboard shortcut to run the script and you're done :). Use the command:



            python3 /path/to/minimize_current.py



          The script



          #!/usr/bin/env python3
          import subprocess

          ignore = [
          "= _NET_WM_WINDOW_TYPE_DOCK",
          "= _NET_WM_WINDOW_TYPE_DESKTOP",
          ]


          def get(cmd):
          return subprocess.check_output(cmd).decode("utf-8").strip()


          def get_currws():
          return [l.split()[0] for l in get(
          ["wmctrl", "-d"]).splitlines() if "*" in l][0]


          def get_valid(w_id):
          # see if the window is a valid one (type)
          w_data = get(["xprop", "-id", w_id])
          if w_data:
          return True if not any([t in w_data for t in ignore]) else False
          else:
          return False

          def get_wmclass(w_id):
          return get(["xprop", "-id", w_id, "WM_CLASS"])


          def get_state(w_id):
          return "window state: Iconic" in get(["xprop", "-id", w_id, "WM_STATE"])


          currws = get_currws()
          allwinsdata = [w.split() for w in get(["wmctrl", "-l"]).splitlines()]
          winsoncurr = [w[0] for w in allwinsdata if w[1] == currws]

          active_w = get(["xdotool", "getactivewindow"])
          activeclass = get_wmclass(active_w)
          relevant = [w for w in winsoncurr if get_valid(w)]


          # windows on current workspace, normal state
          tominimize = [
          w for w in relevant if all(
          [not get_state(w), get_wmclass(w) == activeclass]
          )
          ]

          if tominimize:
          for w in tominimize:
          subprocess.Popen(["xdotool", "windowminimize", w])





          share|improve this answer














          OK, just a quick one for fun :)



          Minimize windows of currently active application



          You could use a stripped-down/edited version of this script, which comes with a default Ubuntu Budgie install.
          While the original script toggles the desktop, the edited one below minimizes all windows, on current workspace, of the currently active WM_CLASS.



          The script, how to use





          • Make sure you have both xdotool and wmctrl installed:



            sudo apt install wmctrl xdotool


          • Copy the script below into an empty file, save it as minimize_current.py


          • Create a keyboard shortcut to run the script and you're done :). Use the command:



            python3 /path/to/minimize_current.py



          The script



          #!/usr/bin/env python3
          import subprocess

          ignore = [
          "= _NET_WM_WINDOW_TYPE_DOCK",
          "= _NET_WM_WINDOW_TYPE_DESKTOP",
          ]


          def get(cmd):
          return subprocess.check_output(cmd).decode("utf-8").strip()


          def get_currws():
          return [l.split()[0] for l in get(
          ["wmctrl", "-d"]).splitlines() if "*" in l][0]


          def get_valid(w_id):
          # see if the window is a valid one (type)
          w_data = get(["xprop", "-id", w_id])
          if w_data:
          return True if not any([t in w_data for t in ignore]) else False
          else:
          return False

          def get_wmclass(w_id):
          return get(["xprop", "-id", w_id, "WM_CLASS"])


          def get_state(w_id):
          return "window state: Iconic" in get(["xprop", "-id", w_id, "WM_STATE"])


          currws = get_currws()
          allwinsdata = [w.split() for w in get(["wmctrl", "-l"]).splitlines()]
          winsoncurr = [w[0] for w in allwinsdata if w[1] == currws]

          active_w = get(["xdotool", "getactivewindow"])
          activeclass = get_wmclass(active_w)
          relevant = [w for w in winsoncurr if get_valid(w)]


          # windows on current workspace, normal state
          tominimize = [
          w for w in relevant if all(
          [not get_state(w), get_wmclass(w) == activeclass]
          )
          ]

          if tominimize:
          for w in tominimize:
          subprocess.Popen(["xdotool", "windowminimize", w])






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited yesterday

























          answered yesterday









          Jacob VlijmJacob Vlijm

          63.6k9124218




          63.6k9124218








          • 2




            Since this uses xdotool this only works when using X-server and not with Wayland, right?
            – Graipher
            19 hours ago






          • 2




            @Graipher That is correct. Xdotool nor wmctrl will work on Wayland.
            – Jacob Vlijm
            19 hours ago














          • 2




            Since this uses xdotool this only works when using X-server and not with Wayland, right?
            – Graipher
            19 hours ago






          • 2




            @Graipher That is correct. Xdotool nor wmctrl will work on Wayland.
            – Jacob Vlijm
            19 hours ago








          2




          2




          Since this uses xdotool this only works when using X-server and not with Wayland, right?
          – Graipher
          19 hours ago




          Since this uses xdotool this only works when using X-server and not with Wayland, right?
          – Graipher
          19 hours ago




          2




          2




          @Graipher That is correct. Xdotool nor wmctrl will work on Wayland.
          – Jacob Vlijm
          19 hours ago




          @Graipher That is correct. Xdotool nor wmctrl will work on Wayland.
          – Jacob Vlijm
          19 hours ago













          6














          This is not a keyboard shortcut, but another way to minimise all windows of an application. You can enable 'minimise on click' in Ubuntu dock. Then once you click an application icon in the dock, it would minimise all windows (or raise, if they're already minimised) of that application.



          To enable this option, run the following command in Terminal:



          gsettings set org.gnome.shell.extensions.dash-to-dock click-action 'minimize'


          (Reference: How do I enable 'minimize on click' on Ubuntu dock in Ubuntu 17.10 and later?)






          share|improve this answer























          • That is really useful to know, thank you! +1 I am gonna decline to accept this answer for the time being, both because "too soon" and because others may have a keyboard shortcut solution. This answer is definitely in the running though. :)
            – Lexible
            yesterday








          • 1




            @Lexible Sure, I would recommend not accepting too :) For the same reason I didn't vote to close as a duplicate of the other question.
            – pomsky
            yesterday
















          6














          This is not a keyboard shortcut, but another way to minimise all windows of an application. You can enable 'minimise on click' in Ubuntu dock. Then once you click an application icon in the dock, it would minimise all windows (or raise, if they're already minimised) of that application.



          To enable this option, run the following command in Terminal:



          gsettings set org.gnome.shell.extensions.dash-to-dock click-action 'minimize'


          (Reference: How do I enable 'minimize on click' on Ubuntu dock in Ubuntu 17.10 and later?)






          share|improve this answer























          • That is really useful to know, thank you! +1 I am gonna decline to accept this answer for the time being, both because "too soon" and because others may have a keyboard shortcut solution. This answer is definitely in the running though. :)
            – Lexible
            yesterday








          • 1




            @Lexible Sure, I would recommend not accepting too :) For the same reason I didn't vote to close as a duplicate of the other question.
            – pomsky
            yesterday














          6












          6








          6






          This is not a keyboard shortcut, but another way to minimise all windows of an application. You can enable 'minimise on click' in Ubuntu dock. Then once you click an application icon in the dock, it would minimise all windows (or raise, if they're already minimised) of that application.



          To enable this option, run the following command in Terminal:



          gsettings set org.gnome.shell.extensions.dash-to-dock click-action 'minimize'


          (Reference: How do I enable 'minimize on click' on Ubuntu dock in Ubuntu 17.10 and later?)






          share|improve this answer














          This is not a keyboard shortcut, but another way to minimise all windows of an application. You can enable 'minimise on click' in Ubuntu dock. Then once you click an application icon in the dock, it would minimise all windows (or raise, if they're already minimised) of that application.



          To enable this option, run the following command in Terminal:



          gsettings set org.gnome.shell.extensions.dash-to-dock click-action 'minimize'


          (Reference: How do I enable 'minimize on click' on Ubuntu dock in Ubuntu 17.10 and later?)







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited yesterday

























          answered yesterday









          pomskypomsky

          29k1189115




          29k1189115












          • That is really useful to know, thank you! +1 I am gonna decline to accept this answer for the time being, both because "too soon" and because others may have a keyboard shortcut solution. This answer is definitely in the running though. :)
            – Lexible
            yesterday








          • 1




            @Lexible Sure, I would recommend not accepting too :) For the same reason I didn't vote to close as a duplicate of the other question.
            – pomsky
            yesterday


















          • That is really useful to know, thank you! +1 I am gonna decline to accept this answer for the time being, both because "too soon" and because others may have a keyboard shortcut solution. This answer is definitely in the running though. :)
            – Lexible
            yesterday








          • 1




            @Lexible Sure, I would recommend not accepting too :) For the same reason I didn't vote to close as a duplicate of the other question.
            – pomsky
            yesterday
















          That is really useful to know, thank you! +1 I am gonna decline to accept this answer for the time being, both because "too soon" and because others may have a keyboard shortcut solution. This answer is definitely in the running though. :)
          – Lexible
          yesterday






          That is really useful to know, thank you! +1 I am gonna decline to accept this answer for the time being, both because "too soon" and because others may have a keyboard shortcut solution. This answer is definitely in the running though. :)
          – Lexible
          yesterday






          1




          1




          @Lexible Sure, I would recommend not accepting too :) For the same reason I didn't vote to close as a duplicate of the other question.
          – pomsky
          yesterday




          @Lexible Sure, I would recommend not accepting too :) For the same reason I didn't vote to close as a duplicate of the other question.
          – pomsky
          yesterday










          Lexible is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          Lexible is a new contributor. Be nice, and check out our Code of Conduct.













          Lexible is a new contributor. Be nice, and check out our Code of Conduct.












          Lexible is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Ask Ubuntu!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1107496%2fhow-to-quickly-minimize-all-windows-for-a-single-application%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          An IMO inspired problem

          Management

          Investment