Sway with Nvidia Tutorial

Maybe there are some people that want to try sway with the official Nvidia driver, so I thought I’ll just write down my experience and what I did. Be aware that you could potentially mess things up, so proceed with that in mind.

I’ve been running sway on Nvidia for like a week on my arch install and I have to say it’s working pretty good so far. Even games like Overwatch seem to be running quite well. Although in order to have it running properly I had to compile and install the sway-git package. With an AUR helper the other necessary git packages like f.e. wlroots-git should be pulled and compiled automatically.

So if you installed the community edition, you can just run yay -S sway-git to get the newest needed packages. If it asks you if you want to replace the packages from the repositories just confirm. Also if you don’t have the Nvidia driver installed, you should obviously do that.

From this thread I pulled some things you need to do after that:

  • edit /etc/mkinitcpio.conf so the MODULE line includes nvidia nvidia_modeset nvidia_uvm nvidia_drm. If there is nothing already in there it should look like this: MODULES=(nvidia nvidia_modeset nvidia_uvm nvidia_drm)

  • run sudo mkinitcpio -P to apply the changes

With the previous actions you are making sure the Nvidia driver is loaded as soon as possible.

  • add rd.driver.blacklist=nouveau and nvidia-drm.modeset=1 inside the quotation marks inside the line that starts with GRUB_CMDLINE_LINUX_DEFAULT

That will disable loading the open source driver and enable DRM.

Now you need to make sure sway will use the --unsupported-gpu argument while starting. The EOS community edition uses Ly to start the session. I’m not quite sure where to put this argument with Ly, so maybe someone could tell me where to change it. I’ll edit the post if I found out how.

After everything is done, you can reboot and do the following to see if it worked:

  • run nvidia-smi inside the terminal and see if sway is mentioned inside the “Processes” tab.
  • install vulkan-tools and run vkcube to see if it properly opens a spinning cube.

If you don’t see a mouse cursor, you need to export this environment variable before starting sway: export WLR_NO_HARDWARE_CURSORS=1

This is just a direction on what you have to do in order to get sway somewhat working with an Nvidia GPU, if you want to use the official driver. But keep in mind the sway developers will not support the official closed source Nvidia and if you are having problems, they may never be fixed.

3 Likes

Having done this process a few times, I can tell you that odds are you will need to do some more tweaks than those described here to make it run.

The combination of packages which worked for me have been:

sway-git r6798.0c210a5e-1
wayland-git 1.19.0.r75.gd564823-1
nvidia-egl-wayland-tkg 495.29.05-183
wlroots-eglstreams-git 0.14.1.r5146.8073eb71-1
lib32-nvidia-utils-tkg 495.29.05-183
lib32-opencl-nvidia-tkg 495.29.05-183
nvidia-dkms-tkg 495.29.05-183
nvidia-settings-tkg 495.29.05-183
nvidia-utils-tkg 495.29.05-183
opencl-nvidia-tkg 495.29.05-183

-tkg are from here, the rest can be found with an aur helper. Make sure you have multilib enabled in pacman.conf before you install the -tkg packages.

In addition, depending on what software you need to run, some of these environmental variables may be useful:

export QT_AUTO_SCREEN_SCALE_FACTOR=1
export QT_QPA_PLATFORM=wayland
export QT_WAYLAND_DISABLE_WINDOWDECORATION=1
export GDK_BACKEND=wayland
export XDG_CURRENT_DESKTOP=sway
export GBM_BACKEND=nvidia-drm
export __GLX_VENDOR_LIBRARY_NAME=nvidia
export MOZ_ENABLE_WAYLAND=1
export WLR_NO_HARDWARE_CURSORS=1

Some applications will not function, and you can run most of them under x11 with QT_QPA_PLATFORM=xcb appname.

Most applications run fine for me, with the exception of mpv which causes a bit of flickering, and electron applications which do not run. All in all, I think you’re still better off with x11 if you want a smooth experience - either that or rob a bank so you can afford an AMD card in the current market.

On a personal note I think I’d switch if I had either a better alternative WM - I prefer bspwm - or a more stable experience without the flickering, but having to deal with Sway and the flickering is too much for now.

1 Like

The packages you mention are most likely old recommendations in the linked thread (last edit was mid october if I’m reading it correct).

I’m running the system like I described and it works pretty well. No mpv problems, no flickering or artifacts in general and three games working without any problems so far (Overwatch, Stardew Valley and Valheim). It’s good you are mentioning those environmental variables, because I forgot to mention those.

Well, no. The packages are different variations of what you linked. Depending on what you need/want you can pick and choose. The ‘to make it run’ part is because, having monitored the Nvidia thread since its creation, it is evident there is a lot of variation of what combination of packages and settings will work for each user. For example - and this is still present I believe - the git variations of Sway and wlroots refuse to run for some users (argb8888 & xrgb8888 errors) but the normal variations work, whereas others - like me - can run the git versions fine.

Nvidia do not care about Wayland, and the Sway and wlroots developers do not want to support closed source drivers. Making Sway run with Nvidia’s drivers is a large effort from a small number of dedicated users, and as a result what ‘works’ or does not work varies.

Glad you made it work without issues!

1 Like

AFAIK that was fixed in a recent wlroots commit.

That sure is true. It’s really annoying having to deal with Nvidia. But overall I think sway/wlroots/wayland is generally getting decent with the official Nvidia driver.