How can I open a work space from the command line in i3?









up vote
0
down vote

favorite












I'd like to script opening a workspace with the 'next' available number and then have open in that workspace maybe a two windows each already pointed at a specific view. Any pointers on how to do that? Is i3 actually scriptable in this regard? I have only just started using i3 and loving it, just want to now have it do things I need on a regular basis ;-)










share|improve this question

























    up vote
    0
    down vote

    favorite












    I'd like to script opening a workspace with the 'next' available number and then have open in that workspace maybe a two windows each already pointed at a specific view. Any pointers on how to do that? Is i3 actually scriptable in this regard? I have only just started using i3 and loving it, just want to now have it do things I need on a regular basis ;-)










    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I'd like to script opening a workspace with the 'next' available number and then have open in that workspace maybe a two windows each already pointed at a specific view. Any pointers on how to do that? Is i3 actually scriptable in this regard? I have only just started using i3 and loving it, just want to now have it do things I need on a regular basis ;-)










      share|improve this question













      I'd like to script opening a workspace with the 'next' available number and then have open in that workspace maybe a two windows each already pointed at a specific view. Any pointers on how to do that? Is i3 actually scriptable in this regard? I have only just started using i3 and loving it, just want to now have it do things I need on a regular basis ;-)







      workspace i3






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 9 at 21:11









      lucidquiet

      2,41452961




      2,41452961






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote













          All of i3's "scripting" that isn't already in the config is done through i3-msg



          i3-msg sends messages to i3 window manager. It's mostly config lines(or IPC, which is a bit harder).




          How can I open a work space from the command line in i3




          How do you open it in your config?



          bindsym Mod4+1 workspace $ws1



          Something like that right? Now, using i3-msg to move to workspace 1:



          i3-msg workspace 1



          Simple, right?



          The rest of your question is pretty unclear, but I'll do my best:




          I'd like to script opening a workspace with the "next" available number"




          How you'll start out with doing that is(after doing man i3-msg):



          i3-msg -t get_workspaces



          This returns a json(if you've done any coding you'll feel warm inside and if not you're going to be scared by the output). Then I'm going to ask you to read up on this:



          https://i3wm.org/docs/ipc.html#_receiving_replies_from_i3



          Using jq or something like json.sh to parse through the output with bash, you should get which workspaces are "active", example:



          ["num":3,"name":"3","visible":true,"focused":false,"rect":"x":0,"y":0,"width":1920,"height":1080,"output":"HDMI-1","urgent":false,"num":2,"name":"2","visible":true,"focused":false,"rect":"x":3520,"y":0,"width":1920,"height":1080,"output":"VGA-1","urgent":false,"num":1,"name":"1","visible":true,"focused":true,"rect":"x":1920,"y":32,"width":1600,"height":868,"output":"eDP-1","urgent":false,"num":5,"name":"5","visible":false,"focused":false,"rect":"x":1920,"y":32,"width":1600,"height":868,"output":"eDP-1","urgent":false]


          Reading through the website I gave you, you can see, workspaces 1,2,3 and 5 are "active" aka have windows in them. After parsing the actual json you'll end up with an array or something of this. If you want to spawn on 4(the real "next" desktop) or 6 (aka biggest number + 1) is up to you. You didn't mention what you want to script it in, so I'll leave that to you to figure out.




          maybe two windows each already pointed at a specific view




          I'm not sure what you mean. You probably want 2 windows of X(we'll use a terminal in this case) in the workspace we've determined as "next" ?



          Let's go back to i3-msg for a bit.



          Imagine you doing whatever you're trying to do, manually, as a list of commands you're firing to i3.



          "Go to workspace X" : i3-msg workspace 4



          "Spawn a program called kitty there": kitty



          "Split vertically and spawn another program": i3-msg split v



          "Spawn another kitty window": kitty



          After that you can get back to your current workspace(I suggest saving it in a variable and just reusing i3-msg workspace $curr_workspace).



          As I said, the question wasn't about the actual scripting so I left that out to figure it out on your own, but don't hesitate to ask a concrete question under the bash tag. :). Hopefully I didn't completely misunderstand your question.



          Welcome to the i3 community.






          share|improve this answer




















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            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',
            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%2fstackoverflow.com%2fquestions%2f53233320%2fhow-can-i-open-a-work-space-from-the-command-line-in-i3%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








            up vote
            1
            down vote













            All of i3's "scripting" that isn't already in the config is done through i3-msg



            i3-msg sends messages to i3 window manager. It's mostly config lines(or IPC, which is a bit harder).




            How can I open a work space from the command line in i3




            How do you open it in your config?



            bindsym Mod4+1 workspace $ws1



            Something like that right? Now, using i3-msg to move to workspace 1:



            i3-msg workspace 1



            Simple, right?



            The rest of your question is pretty unclear, but I'll do my best:




            I'd like to script opening a workspace with the "next" available number"




            How you'll start out with doing that is(after doing man i3-msg):



            i3-msg -t get_workspaces



            This returns a json(if you've done any coding you'll feel warm inside and if not you're going to be scared by the output). Then I'm going to ask you to read up on this:



            https://i3wm.org/docs/ipc.html#_receiving_replies_from_i3



            Using jq or something like json.sh to parse through the output with bash, you should get which workspaces are "active", example:



            ["num":3,"name":"3","visible":true,"focused":false,"rect":"x":0,"y":0,"width":1920,"height":1080,"output":"HDMI-1","urgent":false,"num":2,"name":"2","visible":true,"focused":false,"rect":"x":3520,"y":0,"width":1920,"height":1080,"output":"VGA-1","urgent":false,"num":1,"name":"1","visible":true,"focused":true,"rect":"x":1920,"y":32,"width":1600,"height":868,"output":"eDP-1","urgent":false,"num":5,"name":"5","visible":false,"focused":false,"rect":"x":1920,"y":32,"width":1600,"height":868,"output":"eDP-1","urgent":false]


            Reading through the website I gave you, you can see, workspaces 1,2,3 and 5 are "active" aka have windows in them. After parsing the actual json you'll end up with an array or something of this. If you want to spawn on 4(the real "next" desktop) or 6 (aka biggest number + 1) is up to you. You didn't mention what you want to script it in, so I'll leave that to you to figure out.




            maybe two windows each already pointed at a specific view




            I'm not sure what you mean. You probably want 2 windows of X(we'll use a terminal in this case) in the workspace we've determined as "next" ?



            Let's go back to i3-msg for a bit.



            Imagine you doing whatever you're trying to do, manually, as a list of commands you're firing to i3.



            "Go to workspace X" : i3-msg workspace 4



            "Spawn a program called kitty there": kitty



            "Split vertically and spawn another program": i3-msg split v



            "Spawn another kitty window": kitty



            After that you can get back to your current workspace(I suggest saving it in a variable and just reusing i3-msg workspace $curr_workspace).



            As I said, the question wasn't about the actual scripting so I left that out to figure it out on your own, but don't hesitate to ask a concrete question under the bash tag. :). Hopefully I didn't completely misunderstand your question.



            Welcome to the i3 community.






            share|improve this answer
























              up vote
              1
              down vote













              All of i3's "scripting" that isn't already in the config is done through i3-msg



              i3-msg sends messages to i3 window manager. It's mostly config lines(or IPC, which is a bit harder).




              How can I open a work space from the command line in i3




              How do you open it in your config?



              bindsym Mod4+1 workspace $ws1



              Something like that right? Now, using i3-msg to move to workspace 1:



              i3-msg workspace 1



              Simple, right?



              The rest of your question is pretty unclear, but I'll do my best:




              I'd like to script opening a workspace with the "next" available number"




              How you'll start out with doing that is(after doing man i3-msg):



              i3-msg -t get_workspaces



              This returns a json(if you've done any coding you'll feel warm inside and if not you're going to be scared by the output). Then I'm going to ask you to read up on this:



              https://i3wm.org/docs/ipc.html#_receiving_replies_from_i3



              Using jq or something like json.sh to parse through the output with bash, you should get which workspaces are "active", example:



              ["num":3,"name":"3","visible":true,"focused":false,"rect":"x":0,"y":0,"width":1920,"height":1080,"output":"HDMI-1","urgent":false,"num":2,"name":"2","visible":true,"focused":false,"rect":"x":3520,"y":0,"width":1920,"height":1080,"output":"VGA-1","urgent":false,"num":1,"name":"1","visible":true,"focused":true,"rect":"x":1920,"y":32,"width":1600,"height":868,"output":"eDP-1","urgent":false,"num":5,"name":"5","visible":false,"focused":false,"rect":"x":1920,"y":32,"width":1600,"height":868,"output":"eDP-1","urgent":false]


              Reading through the website I gave you, you can see, workspaces 1,2,3 and 5 are "active" aka have windows in them. After parsing the actual json you'll end up with an array or something of this. If you want to spawn on 4(the real "next" desktop) or 6 (aka biggest number + 1) is up to you. You didn't mention what you want to script it in, so I'll leave that to you to figure out.




              maybe two windows each already pointed at a specific view




              I'm not sure what you mean. You probably want 2 windows of X(we'll use a terminal in this case) in the workspace we've determined as "next" ?



              Let's go back to i3-msg for a bit.



              Imagine you doing whatever you're trying to do, manually, as a list of commands you're firing to i3.



              "Go to workspace X" : i3-msg workspace 4



              "Spawn a program called kitty there": kitty



              "Split vertically and spawn another program": i3-msg split v



              "Spawn another kitty window": kitty



              After that you can get back to your current workspace(I suggest saving it in a variable and just reusing i3-msg workspace $curr_workspace).



              As I said, the question wasn't about the actual scripting so I left that out to figure it out on your own, but don't hesitate to ask a concrete question under the bash tag. :). Hopefully I didn't completely misunderstand your question.



              Welcome to the i3 community.






              share|improve this answer






















                up vote
                1
                down vote










                up vote
                1
                down vote









                All of i3's "scripting" that isn't already in the config is done through i3-msg



                i3-msg sends messages to i3 window manager. It's mostly config lines(or IPC, which is a bit harder).




                How can I open a work space from the command line in i3




                How do you open it in your config?



                bindsym Mod4+1 workspace $ws1



                Something like that right? Now, using i3-msg to move to workspace 1:



                i3-msg workspace 1



                Simple, right?



                The rest of your question is pretty unclear, but I'll do my best:




                I'd like to script opening a workspace with the "next" available number"




                How you'll start out with doing that is(after doing man i3-msg):



                i3-msg -t get_workspaces



                This returns a json(if you've done any coding you'll feel warm inside and if not you're going to be scared by the output). Then I'm going to ask you to read up on this:



                https://i3wm.org/docs/ipc.html#_receiving_replies_from_i3



                Using jq or something like json.sh to parse through the output with bash, you should get which workspaces are "active", example:



                ["num":3,"name":"3","visible":true,"focused":false,"rect":"x":0,"y":0,"width":1920,"height":1080,"output":"HDMI-1","urgent":false,"num":2,"name":"2","visible":true,"focused":false,"rect":"x":3520,"y":0,"width":1920,"height":1080,"output":"VGA-1","urgent":false,"num":1,"name":"1","visible":true,"focused":true,"rect":"x":1920,"y":32,"width":1600,"height":868,"output":"eDP-1","urgent":false,"num":5,"name":"5","visible":false,"focused":false,"rect":"x":1920,"y":32,"width":1600,"height":868,"output":"eDP-1","urgent":false]


                Reading through the website I gave you, you can see, workspaces 1,2,3 and 5 are "active" aka have windows in them. After parsing the actual json you'll end up with an array or something of this. If you want to spawn on 4(the real "next" desktop) or 6 (aka biggest number + 1) is up to you. You didn't mention what you want to script it in, so I'll leave that to you to figure out.




                maybe two windows each already pointed at a specific view




                I'm not sure what you mean. You probably want 2 windows of X(we'll use a terminal in this case) in the workspace we've determined as "next" ?



                Let's go back to i3-msg for a bit.



                Imagine you doing whatever you're trying to do, manually, as a list of commands you're firing to i3.



                "Go to workspace X" : i3-msg workspace 4



                "Spawn a program called kitty there": kitty



                "Split vertically and spawn another program": i3-msg split v



                "Spawn another kitty window": kitty



                After that you can get back to your current workspace(I suggest saving it in a variable and just reusing i3-msg workspace $curr_workspace).



                As I said, the question wasn't about the actual scripting so I left that out to figure it out on your own, but don't hesitate to ask a concrete question under the bash tag. :). Hopefully I didn't completely misunderstand your question.



                Welcome to the i3 community.






                share|improve this answer












                All of i3's "scripting" that isn't already in the config is done through i3-msg



                i3-msg sends messages to i3 window manager. It's mostly config lines(or IPC, which is a bit harder).




                How can I open a work space from the command line in i3




                How do you open it in your config?



                bindsym Mod4+1 workspace $ws1



                Something like that right? Now, using i3-msg to move to workspace 1:



                i3-msg workspace 1



                Simple, right?



                The rest of your question is pretty unclear, but I'll do my best:




                I'd like to script opening a workspace with the "next" available number"




                How you'll start out with doing that is(after doing man i3-msg):



                i3-msg -t get_workspaces



                This returns a json(if you've done any coding you'll feel warm inside and if not you're going to be scared by the output). Then I'm going to ask you to read up on this:



                https://i3wm.org/docs/ipc.html#_receiving_replies_from_i3



                Using jq or something like json.sh to parse through the output with bash, you should get which workspaces are "active", example:



                ["num":3,"name":"3","visible":true,"focused":false,"rect":"x":0,"y":0,"width":1920,"height":1080,"output":"HDMI-1","urgent":false,"num":2,"name":"2","visible":true,"focused":false,"rect":"x":3520,"y":0,"width":1920,"height":1080,"output":"VGA-1","urgent":false,"num":1,"name":"1","visible":true,"focused":true,"rect":"x":1920,"y":32,"width":1600,"height":868,"output":"eDP-1","urgent":false,"num":5,"name":"5","visible":false,"focused":false,"rect":"x":1920,"y":32,"width":1600,"height":868,"output":"eDP-1","urgent":false]


                Reading through the website I gave you, you can see, workspaces 1,2,3 and 5 are "active" aka have windows in them. After parsing the actual json you'll end up with an array or something of this. If you want to spawn on 4(the real "next" desktop) or 6 (aka biggest number + 1) is up to you. You didn't mention what you want to script it in, so I'll leave that to you to figure out.




                maybe two windows each already pointed at a specific view




                I'm not sure what you mean. You probably want 2 windows of X(we'll use a terminal in this case) in the workspace we've determined as "next" ?



                Let's go back to i3-msg for a bit.



                Imagine you doing whatever you're trying to do, manually, as a list of commands you're firing to i3.



                "Go to workspace X" : i3-msg workspace 4



                "Spawn a program called kitty there": kitty



                "Split vertically and spawn another program": i3-msg split v



                "Spawn another kitty window": kitty



                After that you can get back to your current workspace(I suggest saving it in a variable and just reusing i3-msg workspace $curr_workspace).



                As I said, the question wasn't about the actual scripting so I left that out to figure it out on your own, but don't hesitate to ask a concrete question under the bash tag. :). Hopefully I didn't completely misunderstand your question.



                Welcome to the i3 community.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 11 at 13:39









                Nephilim

                106110




                106110



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53233320%2fhow-can-i-open-a-work-space-from-the-command-line-in-i3%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

                    How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

                    Syphilis

                    Darth Vader #20