How to determine if window is maximised or minimised from bash scriptHow to close, minimize, and maximize a specified window from Terminal?Problem with using wmctrl to arrange windows in compizHow to determine status of upstart job in bash script?Bash escape from scriptHow do I use wmctrl to detect if a window is present?How do I permanently change window titles?Executing wmctrl from bashsleep X - won't actually make bash script loop waitSet window size and positionObtain last active time of window from IDFrom a bash script, send commands to a terminal window

cryptic clue: mammal sounds like relative consumer (8)

How can bays and straits be determined in a procedurally generated map?

Is there really no realistic way for a skeleton monster to move around without magic?

Can Medicine checks be used, with decent rolls, to completely mitigate the risk of death from ongoing damage?

Download, install and reboot computer at night if needed

When blogging recipes, how can I support both readers who want the narrative/journey and ones who want the printer-friendly recipe?

What is the meaning of "of trouble" in the following sentence?

How to determine if window is maximised or minimised from bash script

Circuitry of TV splitters

Why Is Death Allowed In the Matrix?

Extreme, but not acceptable situation and I can't start the work tomorrow morning

The use of multiple foreign keys on same column in SQL Server

What makes Graph invariants so useful/important?

Why is this code 6.5x slower with optimizations enabled?

What typically incentivizes a professor to change jobs to a lower ranking university?

N.B. ligature in Latex

Patience, young "Padovan"

DOS, create pipe for stdin/stdout of command.com(or 4dos.com) in C or Batch?

Could a US political party gain complete control over the government by removing checks & balances?

Why doesn't Newton's third law mean a person bounces back to where they started when they hit the ground?

Email Account under attack (really) - anything I can do?

Why are 150k or 200k jobs considered good when there are 300k+ births a month?

Is it possible to do 50 km distance without any previous training?

How do we improve the relationship with a client software team that performs poorly and is becoming less collaborative?



How to determine if window is maximised or minimised from bash script


How to close, minimize, and maximize a specified window from Terminal?Problem with using wmctrl to arrange windows in compizHow to determine status of upstart job in bash script?Bash escape from scriptHow do I use wmctrl to detect if a window is present?How do I permanently change window titles?Executing wmctrl from bashsleep X - won't actually make bash script loop waitSet window size and positionObtain last active time of window from IDFrom a bash script, send commands to a terminal window






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








4















I have a bash script that moves my windows from the left screen to right screen in dual-screen setup. Currently the way it works is cycling through the window ids that are given by xdotool search --onlyvisible --maxdepth 2 --class "" and then moves them to the right by the screen width. It already works... unless the window in question is maximises or minimised.



So what is needed is a way to check the current status of the window. I have found an answer that provides the way to add and remove those bits, but where is the way to check if they are set already?



If it is not possible to do via xdotool, it should be possible to reuse the window id provided by the command mentioned above.










share|improve this question




























    4















    I have a bash script that moves my windows from the left screen to right screen in dual-screen setup. Currently the way it works is cycling through the window ids that are given by xdotool search --onlyvisible --maxdepth 2 --class "" and then moves them to the right by the screen width. It already works... unless the window in question is maximises or minimised.



    So what is needed is a way to check the current status of the window. I have found an answer that provides the way to add and remove those bits, but where is the way to check if they are set already?



    If it is not possible to do via xdotool, it should be possible to reuse the window id provided by the command mentioned above.










    share|improve this question
























      4












      4








      4








      I have a bash script that moves my windows from the left screen to right screen in dual-screen setup. Currently the way it works is cycling through the window ids that are given by xdotool search --onlyvisible --maxdepth 2 --class "" and then moves them to the right by the screen width. It already works... unless the window in question is maximises or minimised.



      So what is needed is a way to check the current status of the window. I have found an answer that provides the way to add and remove those bits, but where is the way to check if they are set already?



      If it is not possible to do via xdotool, it should be possible to reuse the window id provided by the command mentioned above.










      share|improve this question














      I have a bash script that moves my windows from the left screen to right screen in dual-screen setup. Currently the way it works is cycling through the window ids that are given by xdotool search --onlyvisible --maxdepth 2 --class "" and then moves them to the right by the screen width. It already works... unless the window in question is maximises or minimised.



      So what is needed is a way to check the current status of the window. I have found an answer that provides the way to add and remove those bits, but where is the way to check if they are set already?



      If it is not possible to do via xdotool, it should be possible to reuse the window id provided by the command mentioned above.







      bash xdotool wmctrl






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 2 hours ago









      v010dyav010dya

      5872728




      5872728




















          1 Answer
          1






          active

          oldest

          votes


















          4














          Retrieve info on the window state



          You can get the info (and a lot more) from the command:



          xprop -id <window_id>


          To get what you are specifically looking for:



          xprop -id 0x04c00010 | grep "_NET_WM_STATE(ATOM)"


          The output will look like:



          _NET_WM_STATE(ATOM) = _NET_WM_STATE_MAXIMIZED_HORZ, _NET_WM_STATE_MAXIMIZED_VERT, _NET_WM_STATE_HIDDEN


          on a window that is maximized (h + v) and minimized at the same time, or just



          _NET_WM_STATE(ATOM) =


          (or no output at all) if none of those is the case.



          More fun



          Of course, using various languages, you can use Wnck, like in the python snippet below. The snippet outputs a list, showing the window name + either True or False (minimized).



          #!/usr/bin/env python3
          import gi
          gi.require_version('Wnck', '3.0')
          from gi.repository import Wnck


          def get_winlist(scr=None, selecttype=None):
          """
          get the window list. possible args: screen, select_type, in case it is
          already fetched elsewhere. select type is optional, to fetch only
          specific window types.
          """
          if not scr:
          scr = Wnck.Screen.get_default()
          scr.force_update()
          windows = scr.get_windows()
          if selecttype:
          windows = [w for w in windows if check_windowtype(w, selecttype)]
          return windows

          wlist = get_winlist()
          for w in wlist:
          print(w.get_name(), ",", w.is_maximized())


          Output looks like:



          Wnck.Window - Classes - Wnck 3.0 - Mozilla Firefox , True
          Postvak IN - vlijm@planet.nl - Mozilla Thunderbird , True
          Showtime , False
          settingsexample.vala - Visual Studio Code , False
          *Niet-opgeslagen document 1 - gedit , False
          desktop_weather , False
          Tilix: Standaard , False





          share|improve this answer

























          • Excellent suggestion +1. As a comment, I tried it (under Linux, X11) and got slightly different results. When a window is neither hidden nor maximized, _NET_WM_STATE(ATOM) does not, as shown in the answer, appear with an empty value. Instead, it is not in the output at all.

            – John1024
            1 hour ago











          • @John1024 Ah, thanks! will add it to the answer.

            – Jacob Vlijm
            1 hour ago











          • On my system it is shown in either case, even when empty.

            – v010dya
            2 mins ago











          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
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1132023%2fhow-to-determine-if-window-is-maximised-or-minimised-from-bash-script%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          4














          Retrieve info on the window state



          You can get the info (and a lot more) from the command:



          xprop -id <window_id>


          To get what you are specifically looking for:



          xprop -id 0x04c00010 | grep "_NET_WM_STATE(ATOM)"


          The output will look like:



          _NET_WM_STATE(ATOM) = _NET_WM_STATE_MAXIMIZED_HORZ, _NET_WM_STATE_MAXIMIZED_VERT, _NET_WM_STATE_HIDDEN


          on a window that is maximized (h + v) and minimized at the same time, or just



          _NET_WM_STATE(ATOM) =


          (or no output at all) if none of those is the case.



          More fun



          Of course, using various languages, you can use Wnck, like in the python snippet below. The snippet outputs a list, showing the window name + either True or False (minimized).



          #!/usr/bin/env python3
          import gi
          gi.require_version('Wnck', '3.0')
          from gi.repository import Wnck


          def get_winlist(scr=None, selecttype=None):
          """
          get the window list. possible args: screen, select_type, in case it is
          already fetched elsewhere. select type is optional, to fetch only
          specific window types.
          """
          if not scr:
          scr = Wnck.Screen.get_default()
          scr.force_update()
          windows = scr.get_windows()
          if selecttype:
          windows = [w for w in windows if check_windowtype(w, selecttype)]
          return windows

          wlist = get_winlist()
          for w in wlist:
          print(w.get_name(), ",", w.is_maximized())


          Output looks like:



          Wnck.Window - Classes - Wnck 3.0 - Mozilla Firefox , True
          Postvak IN - vlijm@planet.nl - Mozilla Thunderbird , True
          Showtime , False
          settingsexample.vala - Visual Studio Code , False
          *Niet-opgeslagen document 1 - gedit , False
          desktop_weather , False
          Tilix: Standaard , False





          share|improve this answer

























          • Excellent suggestion +1. As a comment, I tried it (under Linux, X11) and got slightly different results. When a window is neither hidden nor maximized, _NET_WM_STATE(ATOM) does not, as shown in the answer, appear with an empty value. Instead, it is not in the output at all.

            – John1024
            1 hour ago











          • @John1024 Ah, thanks! will add it to the answer.

            – Jacob Vlijm
            1 hour ago











          • On my system it is shown in either case, even when empty.

            – v010dya
            2 mins ago















          4














          Retrieve info on the window state



          You can get the info (and a lot more) from the command:



          xprop -id <window_id>


          To get what you are specifically looking for:



          xprop -id 0x04c00010 | grep "_NET_WM_STATE(ATOM)"


          The output will look like:



          _NET_WM_STATE(ATOM) = _NET_WM_STATE_MAXIMIZED_HORZ, _NET_WM_STATE_MAXIMIZED_VERT, _NET_WM_STATE_HIDDEN


          on a window that is maximized (h + v) and minimized at the same time, or just



          _NET_WM_STATE(ATOM) =


          (or no output at all) if none of those is the case.



          More fun



          Of course, using various languages, you can use Wnck, like in the python snippet below. The snippet outputs a list, showing the window name + either True or False (minimized).



          #!/usr/bin/env python3
          import gi
          gi.require_version('Wnck', '3.0')
          from gi.repository import Wnck


          def get_winlist(scr=None, selecttype=None):
          """
          get the window list. possible args: screen, select_type, in case it is
          already fetched elsewhere. select type is optional, to fetch only
          specific window types.
          """
          if not scr:
          scr = Wnck.Screen.get_default()
          scr.force_update()
          windows = scr.get_windows()
          if selecttype:
          windows = [w for w in windows if check_windowtype(w, selecttype)]
          return windows

          wlist = get_winlist()
          for w in wlist:
          print(w.get_name(), ",", w.is_maximized())


          Output looks like:



          Wnck.Window - Classes - Wnck 3.0 - Mozilla Firefox , True
          Postvak IN - vlijm@planet.nl - Mozilla Thunderbird , True
          Showtime , False
          settingsexample.vala - Visual Studio Code , False
          *Niet-opgeslagen document 1 - gedit , False
          desktop_weather , False
          Tilix: Standaard , False





          share|improve this answer

























          • Excellent suggestion +1. As a comment, I tried it (under Linux, X11) and got slightly different results. When a window is neither hidden nor maximized, _NET_WM_STATE(ATOM) does not, as shown in the answer, appear with an empty value. Instead, it is not in the output at all.

            – John1024
            1 hour ago











          • @John1024 Ah, thanks! will add it to the answer.

            – Jacob Vlijm
            1 hour ago











          • On my system it is shown in either case, even when empty.

            – v010dya
            2 mins ago













          4












          4








          4







          Retrieve info on the window state



          You can get the info (and a lot more) from the command:



          xprop -id <window_id>


          To get what you are specifically looking for:



          xprop -id 0x04c00010 | grep "_NET_WM_STATE(ATOM)"


          The output will look like:



          _NET_WM_STATE(ATOM) = _NET_WM_STATE_MAXIMIZED_HORZ, _NET_WM_STATE_MAXIMIZED_VERT, _NET_WM_STATE_HIDDEN


          on a window that is maximized (h + v) and minimized at the same time, or just



          _NET_WM_STATE(ATOM) =


          (or no output at all) if none of those is the case.



          More fun



          Of course, using various languages, you can use Wnck, like in the python snippet below. The snippet outputs a list, showing the window name + either True or False (minimized).



          #!/usr/bin/env python3
          import gi
          gi.require_version('Wnck', '3.0')
          from gi.repository import Wnck


          def get_winlist(scr=None, selecttype=None):
          """
          get the window list. possible args: screen, select_type, in case it is
          already fetched elsewhere. select type is optional, to fetch only
          specific window types.
          """
          if not scr:
          scr = Wnck.Screen.get_default()
          scr.force_update()
          windows = scr.get_windows()
          if selecttype:
          windows = [w for w in windows if check_windowtype(w, selecttype)]
          return windows

          wlist = get_winlist()
          for w in wlist:
          print(w.get_name(), ",", w.is_maximized())


          Output looks like:



          Wnck.Window - Classes - Wnck 3.0 - Mozilla Firefox , True
          Postvak IN - vlijm@planet.nl - Mozilla Thunderbird , True
          Showtime , False
          settingsexample.vala - Visual Studio Code , False
          *Niet-opgeslagen document 1 - gedit , False
          desktop_weather , False
          Tilix: Standaard , False





          share|improve this answer















          Retrieve info on the window state



          You can get the info (and a lot more) from the command:



          xprop -id <window_id>


          To get what you are specifically looking for:



          xprop -id 0x04c00010 | grep "_NET_WM_STATE(ATOM)"


          The output will look like:



          _NET_WM_STATE(ATOM) = _NET_WM_STATE_MAXIMIZED_HORZ, _NET_WM_STATE_MAXIMIZED_VERT, _NET_WM_STATE_HIDDEN


          on a window that is maximized (h + v) and minimized at the same time, or just



          _NET_WM_STATE(ATOM) =


          (or no output at all) if none of those is the case.



          More fun



          Of course, using various languages, you can use Wnck, like in the python snippet below. The snippet outputs a list, showing the window name + either True or False (minimized).



          #!/usr/bin/env python3
          import gi
          gi.require_version('Wnck', '3.0')
          from gi.repository import Wnck


          def get_winlist(scr=None, selecttype=None):
          """
          get the window list. possible args: screen, select_type, in case it is
          already fetched elsewhere. select type is optional, to fetch only
          specific window types.
          """
          if not scr:
          scr = Wnck.Screen.get_default()
          scr.force_update()
          windows = scr.get_windows()
          if selecttype:
          windows = [w for w in windows if check_windowtype(w, selecttype)]
          return windows

          wlist = get_winlist()
          for w in wlist:
          print(w.get_name(), ",", w.is_maximized())


          Output looks like:



          Wnck.Window - Classes - Wnck 3.0 - Mozilla Firefox , True
          Postvak IN - vlijm@planet.nl - Mozilla Thunderbird , True
          Showtime , False
          settingsexample.vala - Visual Studio Code , False
          *Niet-opgeslagen document 1 - gedit , False
          desktop_weather , False
          Tilix: Standaard , False






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 28 secs ago

























          answered 1 hour ago









          Jacob VlijmJacob Vlijm

          66.2k9131230




          66.2k9131230












          • Excellent suggestion +1. As a comment, I tried it (under Linux, X11) and got slightly different results. When a window is neither hidden nor maximized, _NET_WM_STATE(ATOM) does not, as shown in the answer, appear with an empty value. Instead, it is not in the output at all.

            – John1024
            1 hour ago











          • @John1024 Ah, thanks! will add it to the answer.

            – Jacob Vlijm
            1 hour ago











          • On my system it is shown in either case, even when empty.

            – v010dya
            2 mins ago

















          • Excellent suggestion +1. As a comment, I tried it (under Linux, X11) and got slightly different results. When a window is neither hidden nor maximized, _NET_WM_STATE(ATOM) does not, as shown in the answer, appear with an empty value. Instead, it is not in the output at all.

            – John1024
            1 hour ago











          • @John1024 Ah, thanks! will add it to the answer.

            – Jacob Vlijm
            1 hour ago











          • On my system it is shown in either case, even when empty.

            – v010dya
            2 mins ago
















          Excellent suggestion +1. As a comment, I tried it (under Linux, X11) and got slightly different results. When a window is neither hidden nor maximized, _NET_WM_STATE(ATOM) does not, as shown in the answer, appear with an empty value. Instead, it is not in the output at all.

          – John1024
          1 hour ago





          Excellent suggestion +1. As a comment, I tried it (under Linux, X11) and got slightly different results. When a window is neither hidden nor maximized, _NET_WM_STATE(ATOM) does not, as shown in the answer, appear with an empty value. Instead, it is not in the output at all.

          – John1024
          1 hour ago













          @John1024 Ah, thanks! will add it to the answer.

          – Jacob Vlijm
          1 hour ago





          @John1024 Ah, thanks! will add it to the answer.

          – Jacob Vlijm
          1 hour ago













          On my system it is shown in either case, even when empty.

          – v010dya
          2 mins ago





          On my system it is shown in either case, even when empty.

          – v010dya
          2 mins ago

















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1132023%2fhow-to-determine-if-window-is-maximised-or-minimised-from-bash-script%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

          名間水力發電廠 目录 沿革 設施 鄰近設施 註釋 外部連結 导航菜单23°50′10″N 120°42′41″E / 23.83611°N 120.71139°E / 23.83611; 120.7113923°50′10″N 120°42′41″E / 23.83611°N 120.71139°E / 23.83611; 120.71139計畫概要原始内容臺灣第一座BOT 模式開發的水力發電廠-名間水力電廠名間水力發電廠 水利署首件BOT案原始内容《小檔案》名間電廠 首座BOT水力發電廠原始内容名間電廠BOT - 經濟部水利署中區水資源局

          Prove that NP is closed under karp reduction?Space(n) not closed under Karp reductions - what about NTime(n)?Class P is closed under rotation?Prove or disprove that $NL$ is closed under polynomial many-one reductions$mathbfNC_2$ is closed under log-space reductionOn Karp reductionwhen can I know if a class (complexity) is closed under reduction (cook/karp)Check if class $PSPACE$ is closed under polyonomially space reductionIs NPSPACE also closed under polynomial-time reduction and under log-space reduction?Prove PSPACE is closed under complement?Prove PSPACE is closed under union?

          Is my guitar’s action too high? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)Strings too stiff on a recently purchased acoustic guitar | Cort AD880CEIs the action of my guitar really high?Μy little finger is too weak to play guitarWith guitar, how long should I give my fingers to strengthen / callous?When playing a fret the guitar sounds mutedPlaying (Barre) chords up the guitar neckI think my guitar strings are wound too tight and I can't play barre chordsF barre chord on an SG guitarHow to find to the right strings of a barre chord by feel?High action on higher fret on my steel acoustic guitar