Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fedora - How to setup multiple monitors in sway

#1
How to setup multiple monitors in sway

<div><p>Sway is a tiling Wayland compositor which has mostly the same features, look and workflow as the <a href="https://fedoramagazine.org/getting-started-i3-window-manager/">i3 X11 window manager</a>. Because Sway uses Wayland instead of X11, the tools to setup X11 don’t always work in sway. This includes tools like <em>xrandr</em>, which are used in X11 window managers or desktops to setup monitors. This is why monitors have to be setup by editing the sway config file, and that’s what this article is about.</p>
<h2><strong>Getting your monitor ID’s</strong></h2>
<p>First, you have to get the names sway uses to refer to your monitors. You can do this by running:</p>
<pre class="wp-block-preformatted">$ swaymsg -t get_outputs</pre>
<p>You will get information about all of your monitors, every monitor separated by an empty line.</p>
<p>You have to look for the first line of every section, and for what’s after “Output”. For example, when you see a line like “<em>Output DVI-D-1 ‘Philips Consumer Electronics Company’</em>”, the output ID is “DVI-D-1”. Note these ID’s and which physical monitors they belong to.</p>
<h2><strong>Editing the config file</strong></h2>
<p>If you haven’t edited the Sway config file before, you have to copy it to your home directory by running this command:</p>
<pre class="wp-block-preformatted">cp -r /etc/sway/config ~/.config/sway/config</pre>
<p>Now the default config file is located in <em>~/.config/sway </em>and called “config”. You can edit it using any text editor.</p>
<p>Now you have to do a little bit of math. Imagine a grid with the origin in the top left corner. The units of the X and Y coordinates are pixels. The Y axis is inverted. This means that if you, for example, start at the origin and you move 100 pixels to the right and 80 pixels down, your coordinates will be (100, 80).</p>
<p>You have to calculate where your displays are going to end up on this grid. The locations of the displays are specified with the top left pixel. For example, if we want to have a monitor with name HDMI1 and a resolution of 1920×1080, and to the right of it a laptop monitor with name eDP1 and a resolution of 1600×900, you have to type this in your config file:</p>
<pre class="wp-block-preformatted">output HDMI1 pos 0 0
output eDP1 pos 1920 0</pre>
<p>You can also specify the resolutions manually by using the <em>res</em> option: </p>
<pre class="wp-block-preformatted">output HDMI1 pos 0 0 res 1920x1080
output eDP1 pos 1920 0 res 1600x900</pre>
<h2><strong>Binding workspaces to monitors</strong></h2>
<p>Using sway with multiple monitors can be a little bit tricky with workspace management. Luckily, you can bind workspaces to a specific monitor, so you can easily switch to that monitor and use your displays more efficiently. This can simply be done by the workspace command in your config file. For example, if you want to bind workspace 1 and 2 to monitor DVI-D-1 and workspace 8 and 9 to monitor HDMI-A-1, you can do that by using:</p>
<pre class="wp-block-preformatted">workspace 1 output DVI-D-1
workspace 2 output DVI-D-1</pre>
<pre class="wp-block-preformatted">workspace 8 output HDMI-A-1
workspace 9 output HDMI-A-1</pre>
<p>That’s it! These are the basics of multi monitor setup in sway. A more detailed guide can be found at <a href="https://github.com/swaywm/sway/wiki#Multihead">https://github.com/swaywm/sway/wiki#Multihead</a>. </p>
</div>


https://www.sickgaming.net/blog/2020/01/...s-in-sway/
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum software by © MyBB Theme © iAndrew 2016