Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fedora - Using i3 with multiple monitors

#1
Using i3 with multiple monitors

<div style="margin: 5px 5% 10px 5%;"><img src="http://www.sickgaming.net/blog/wp-content/uploads/2019/06/using-i3-with-multiple-monitors.png" width="1024" height="384" title="" alt="" /></div><div><p>Are you using multiple monitors with your Linux workstation? Seeing many things at once might be beneficial. But there are often much more windows in our workflows than physical monitors — and that’s a good thing, because seeing too many things at once might be distracting. So being able to switch what we see on individual monitors seems crucial.</p>
<p>Let’s talk about i3 — a popular tiling window manager that works great with multiple monitors. And there is one handy feature that many other window managers don’t have — the ability to switch workspaces on individual monitors independently.</p>
<h2>Quick introduction to i3</h2>
<p>The Fedora Magazine has already covered i3 about three years ago. And it was one of the most popular articles ever published! Even though that’s not always the case, i3 is pretty stable and that article is still very accurate today. So — not to repeat ourselves too much — this article only covers the very minimum to get i3 up and running, and you’re welcome to go ahead and read it if you’re new to i3 and want to learn more about the basics.</p>
<p>To install i3 on your system, run the following command:</p>
<pre class="wp-block-preformatted">$ sudo dnf install i3</pre>
<p>When that’s done, log out, and on the log in screen choose i3 as your window manager and log back in again.</p>
<p>When you run i3 for the first time, you’ll be asked if you wish to proceed with automatic configuration — answer yes here. After that, you’ll be asked to choose a “mod key”. If you’re not sure here, just accept the default which sets you Windows/Super key as the mod key. You’ll use this key for mostly all the shortcuts within the window manager.</p>
<p>At this point, you should see a little bar at the bottom and an empty screen. Let’s have a look at some of the basic shortcuts.</p>
<p>Open a terminal using:</p>
<pre class="wp-block-preformatted">$mod + enter</pre>
<p>Switch to a second workspace using:</p>
<pre class="wp-block-preformatted">$mod + 2</pre>
<p>Open firefox in two steps, first by:</p>
<pre class="wp-block-preformatted">$mod + d</pre>
<p>… and then by typing “firefox” and pressing enter.</p>
<p>Move it to the first workspace by:</p>
<pre class="wp-block-preformatted">$mod + shift + 1</pre>
<p>… and switch to the first workspace by:</p>
<pre class="wp-block-preformatted">$mod + 1</pre>
<p>At this point, you’ll see a terminal and a firefox window side by side. To close a window, press:</p>
<pre class="wp-block-preformatted">$mod + shift + q</pre>
<p>There are more shortcuts, but these should give you the minimum to get started with i3.</p>
<p>Ah! And to exit i3 (to log out) press:</p>
<pre class="wp-block-preformatted">$mod + shift + e</pre>
<p>… and then confirm using your mouse at the top-right corner.</p>
<h2>Getting multiple screens to work</h2>
<p>Now that we have i3 up and running, let’s put all those screens to work!</p>
<p>To do that, we’ll need to use the command line as i3 is very lightweight and doesn’t have gui to manage additional screens. But don’t worry if that sounds difficult — it’s actually quite starighforward!</p>
<p>The command we’ll use is called xrandr. If you don’t have xrandr on your system, install it by running:</p>
<pre class="wp-block-preformatted">$ sudo dnf install xrandr</pre>
<p>When that’s installed, let’s just go ahead and run it:</p>
<pre class="wp-block-preformatted">$ xrandr</pre>
<p>The output lists all the available outputs, and also indicated which have a screen attached to them (a monitor connedted with a cable) by showing supported resolutions. Good news is that we don’t need to really care about the specific resolutions to make the them work.</p>
<p>This specific example shows a primary screen of a laptop (named eDP1), and a second monitor connected to the HDMI-2 output, physically positionned right of the laptop. To turn it on, run the following command:</p>
<pre class="wp-block-preformatted">$ xrandr --output HDMI-2 --auto --right-of eDP1</pre>
<p>And that’s it! Your screen is now active.</p>
<figure class="wp-block-image"><img src="http://www.sickgaming.net/blog/wp-content/uploads/2019/06/using-i3-with-multiple-monitors.png" alt="" class="wp-image-28476" /><figcaption>Second screen active. The commands shown on this screenshot are slightly different than in the article, as they set a smaller resolution to make the screenshots more readable.</figcaption></figure>
<h2>Managing workspaces on multiple screens</h2>
<p>Switching workspaces and creating new ones on multiple screens is very similar to having just one screen. New workspaces get created on the screen that’s currently active — the one that has your mouse cursor on it.</p>
<p>So, to switch to a specific workspace (or to create a new one in case it doesn’t exist), press:</p>
<pre class="wp-block-preformatted">$mod + NUMBER</pre>
<p>And you can switch workspaces on individual monitors independently!</p>
<figure class="wp-block-image"><img src="http://www.sickgaming.net/blog/wp-content/uploads/2019/06/using-i3-with-multiple-monitors-1.png" alt="" class="wp-image-28472" /><figcaption>Workspace 2 on the left screen, workspace 4 on the right screen.</figcaption></figure>
<figure class="wp-block-image"><img src="http://www.sickgaming.net/blog/wp-content/uploads/2019/06/using-i3-with-multiple-monitors-2.png" alt="" class="wp-image-28473" /><figcaption>Left screen switched to workspace 3, right screen still showing workspace 4.</figcaption></figure>
<figure class="wp-block-image"><img src="http://www.sickgaming.net/blog/wp-content/uploads/2019/06/using-i3-with-multiple-monitors-3.png" alt="" class="wp-image-28474" /><figcaption>Right screen switched to workspace 4, left screen still showing workspace 3.</figcaption></figure>
<h2>Moving workspaces between monitors</h2>
<p>The same way we can move windows to differnet workspaces by the following command:</p>
<pre class="wp-block-preformatted">$mod + shift + NUMBER</pre>
<p>… we can move workspaces to different screens as well. However, there is no default shortcut for this action —&nbsp;so we have to create it first.</p>
<p>To create a custom shortcut, you’ll need to open the configuration file in a text editor of your choice (this article uses&nbsp;<em>vim</em>):</p>
<pre class="wp-block-preformatted">$ vim ~/.config/i3/config</pre>
<p>And add the following lines to the very bottom of the configuration file:</p>
<pre class="wp-block-preformatted"># Moving workspaces between screens <br />bindsym $mod+p move workspace to output right</pre>
<p>Save, close, and to reload and apply the configuration, press:</p>
<pre class="wp-block-preformatted">$mod + shift + r</pre>
<p>Now you’ll be able to move your active workspace to the second monitor by:</p>
<pre class="wp-block-preformatted">$mod + p</pre>
<figure class="wp-block-image"><img src="http://www.sickgaming.net/blog/wp-content/uploads/2019/06/using-i3-with-multiple-monitors-4.png" alt="" class="wp-image-28470" /><figcaption>Workspace 2 with Firefox on the left screen</figcaption></figure>
<figure class="wp-block-image"><img src="http://www.sickgaming.net/blog/wp-content/uploads/2019/06/using-i3-with-multiple-monitors-5.png" alt="" class="wp-image-28471" /><figcaption>Workspace 2 with Firefox moved to the second screen</figcaption></figure>
<p>And that’s it! Enjoy your new multi-monitor experience, and to learn more about i3, you’re welcome to read the previous article about i3 on the Fedora Magazine, or consult the official i3 documentation.</p>
</div>
Reply



Forum Jump:


Users browsing this thread:
2 Guest(s)

Forum software by © MyBB Theme © iAndrew 2016