### Clone and build sway with wlroots subproject Source: https://github.com/swaywm/sway/wiki/Development-Setup Clones the sway repository and wlroots as a subproject, then builds both with meson and ninja. Start sway directly from the build directory without installing. Remember to also pull from the wlroots repo when pulling from the Sway repo. ```sh # Clone repositories git clone https://github.com/swaywm/sway.git cd sway git clone https://gitlab.freedesktop.org/wlroots/wlroots.git subprojects/wlroots # Build sway and wlroots meson setup build/ ninja -C build/ # Start sway build/sway/sway ``` -------------------------------- ### Build and install swaybg 1.0 from source Source: https://github.com/swaywm/sway/wiki/Debian-10-(Buster)-Installation Required for the default configuration to work. Clones the swaybg repository, checks out version 1.0, and installs it. ```bash cd ~/sway-src git clone https://github.com/swaywm/swaybg.git cd swaybg git checkout 1.0 meson build sudo ninja -C build install ``` -------------------------------- ### HiDPI scaling configuration Source: https://github.com/swaywm/sway/wiki/Home Example output configuration with scale 2 on HDMI1 and adjusted positions for eDP1, illustrating how scaling affects relative positions. ```config output HDMI1 scale 2 output HDMI1 pos 0 0 res 3200x1800 output eDP1 pos 1600 0 res 1920x1080 ``` -------------------------------- ### Configure output with mode Source: https://github.com/swaywm/sway/wiki/Home Example of an output block in the sway config that sets a mode with a specific resolution and refresh rate. ```config output { # ...config options... mode 3840x1600@143.998Hz } ``` -------------------------------- ### Auto-start Sway with confirmation prompt Source: https://github.com/swaywm/sway/wiki/Home Prompts for confirmation before starting Sway on TTY1 login. Useful to avoid accidental launches. ```bash # Auto-launch Sway on TTY1 login if [ "$(tty)" = "/dev/tty1" ]; then read -p "Start Sway? [y]es or [n]o: " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]]; then exec sway fi fi ``` -------------------------------- ### Build and install scdoc 1.10.1 from source Source: https://github.com/swaywm/sway/wiki/Debian-10-(Buster)-Installation Required for manual page generation because Debian's stable scdoc version is too old. Clones the scdoc repository, checks out version 1.10.1, and installs it to /usr/local. ```bash cd ~/sway-src git clone https://git.sr.ht/~sircmpwn/scdoc cd scdoc git checkout 1.10.1 make PREFIX=/usr/local -j$CPUCOUNT sudo make PREFIX=/usr/local install ``` -------------------------------- ### Run GUI application as root with sudo Source: https://github.com/swaywm/sway/wiki/Home Fallback option to run a GUI application as root when Polkit is not available. Use as a last resort. ```sh sudo --preserve-env=XDG_RUNTIME_DIR,WAYLAND_DISPLAY ``` -------------------------------- ### Auto-start Sway from .bash_profile Source: https://github.com/swaywm/sway/wiki/Home Adds a check for TTY1 and starts Sway automatically on login. Place in .bash_profile (or .zlogin/.zprofile for Zsh). ```bash # If running from tty1 start sway [ "$(tty)" = "/dev/tty1" ] && exec sway ``` -------------------------------- ### Multiple input device configurations Source: https://github.com/swaywm/sway/wiki/Home Configure different devices with separate blocks. The example shows a default keyboard layout and a custom layout for an external keyboard. ```sway # default layout input "1:1:AT_Translated_Set_2_keyboard" { xkb_layout us } # custom layout for an external keyboard input "1452:591:Custom_Keyboard" { xkb_layout YourCustomLayout } ``` -------------------------------- ### Install Nix build dependencies with nix-shell Source: https://github.com/swaywm/sway/wiki/Development-Setup Uses nix-shell to get all needed packages for building sway. Packages must come from nixpkgs-unstable, and Nix default hardening must be disabled via the NIX_HARDENING_ENABLE environment variable. ```sh nix-shell -p cairo cmake gdk-pixbuf glslang hwdata json_c lcms libGL libcap libdisplay-info libdrm libevdev libgbm libinput libliftoff libxkbcommon mesa meson ninja pango pcre2 pixman pkg-config scdoc seatd tree vulkan-loader wayland wayland-protocols wayland-scanner xorg.xcbutilerrors xorg.xcbutilrenderutil xorg.xcbutilwm xwayland -I nixpkgs=http://channels.nixos.org/nixpkgs-unstable/nixexprs.tar.xz --command "export NIX_HARDENING_ENABLE=; return" ``` -------------------------------- ### Install Sway from nightly Debian repository Source: https://github.com/swaywm/sway/wiki/Debian-10-(Buster)-Installation Adds the quantum2.xyz Sway repository and installs the nightly-built sway package. These packages track master and may be less stable than official releases. ```bash curl -L https://quantum2.xyz/apt.key | sudo apt-key add - echo 'deb [arch=amd64] https://apt.quantum2.xyz/sway-utils/ buster main' | sudo tee /etc/apt/sources.list.d/sway-utils.list sudo apt update sudo apt install sway ``` -------------------------------- ### Run GUI application as root with sudo -E Source: https://github.com/swaywm/sway/wiki/Home Alternative fallback to run a GUI application as root when Polkit is not available. Use as a last resort. ```sh sudo -E ``` -------------------------------- ### Auto-start Sway from Fish shell Source: https://github.com/swaywm/sway/wiki/Home Fish equivalent of the bash auto-start snippet. Create the file ~/.config/fish/conf.d/sway.fish with this content. ```fish # If running from tty1 start sway set TTY1 (tty) [ "$TTY1" = "/dev/tty1" ] && exec sway ``` -------------------------------- ### Focus output on launch via exec Source: https://github.com/swaywm/sway/wiki/Home Alternative to the focus output command that uses exec swaymsg to avoid triggering on reload. ```config exec swaymsg focus output ``` -------------------------------- ### Touch Display Mapping Source: https://github.com/swaywm/sway/wiki/Home Map a touch input device to a specific output in a multi-display setup. The example defines display and touch device variables and maps the touch controller to the touch display. ```sway set $display1 "Dell Inc. DELL P2414H VHVTW542165L" set $display2 "Dell Inc. DELL P2418HT MYDM775F152L" set $display2-touch "8146:24835:Melfas_LGD_AIT_Touch_Controller" input $display2-touch map_to_output $display2 ``` -------------------------------- ### Set wallpaper with output command bg option Source: https://github.com/swaywm/sway/wiki/Home Use the `output` command with the `bg` option to set a wallpaper when swaybg is installed. The example sets the wallpaper for output HDMI-A-1 to ~/wallpaper.png with stretch mode. See `man 5 sway-output` for more options. ```bash output HDMI-A-1 bg ~/wallpaper.png stretch ``` -------------------------------- ### Create config directory and copy default config Source: https://github.com/swaywm/sway/wiki/Home Sets up the sway configuration directory and copies the default config to ~/.config/sway/config, then opens it in your editor. ```sh mkdir -p ~/.config/sway cp /etc/sway/config ~/.config/sway/ $EDITOR ~/.config/sway/config ``` -------------------------------- ### Build and install json-c 0.13.1 Source: https://github.com/swaywm/sway/wiki/Debian-10-(Buster)-Installation Compiles a newer json-c version because Debian's package is too old. Installs to /usr/local and runs ldconfig. ```bash sudo apt install autoconf libtool cd ~/sway-src git clone https://github.com/json-c/json-c.git cd json-c git checkout json-c-0.13.1-20180305 sh autogen.sh ./configure --enable-threading --prefix=/usr/local CPUCOUNT=$(nproc) make -j$CPUCOUNT sudo make install sudo ldconfig ``` -------------------------------- ### Install sway 1.4 dependencies and build from source Source: https://github.com/swaywm/sway/wiki/Debian-10-(Buster)-Installation Installs required packages and builds sway 1.4 from source using meson and ninja. The git checkout ensures version 1.4 is used. ```bash sudo apt install libpcre3-dev libcairo2-dev libpango1.0-dev libgdk-pixbuf2.0-dev xwayland cd ~/sway-src git clone https://github.com/swaywm/sway.git cd sway git checkout 1.4 meson build sudo ninja -C build install ``` -------------------------------- ### Add Xft.dpi to ~/.Xresources Source: https://github.com/swaywm/sway/wiki/Home Add this line to ~/.Xresources to fix oversized text after Xwayland DPI changes or HiDPI issues. ```xresources Xft.dpi: 96 ``` -------------------------------- ### Install wlroots 0.10 dependencies and build Source: https://github.com/swaywm/sway/wiki/Debian-10-(Buster)-Installation Installs build dependencies and compiles wlroots 0.10.0 from source. Requires meson >= 0.53.1 and ninja-build >= 1.6. ```bash sudo apt install build-essential cmake libwayland-dev wayland-protocols \ libegl1-mesa-dev libgles2-mesa-dev libdrm-dev libgbm-dev libinput-dev \ libxkbcommon-dev libudev-dev libpixman-1-dev libsystemd-dev libcap-dev \ libxcb1-dev libxcb-composite0-dev libxcb-xfixes0-dev libxcb-xinput-dev \ libxcb-image0-dev libxcb-render-util0-dev libx11-xcb-dev libxcb-icccm4-dev \ freerdp2-dev libwinpr2-dev libpng-dev libavutil-dev libavcodec-dev \ libavformat-dev universal-ctags sudo apt install libelogind-dev libxcb-util0-dev cd ~/sway-src git clone https://github.com/swaywm/wlroots.git cd wlroots git checkout 0.10.0 meson build sudo ninja -C build install ``` -------------------------------- ### Compile and install sway from source with meson Source: https://github.com/swaywm/sway/blob/master/README.md Build sway from source after installing dependencies. Run these commands in the sway source directory to set up the build, compile, and install. ```shell meson setup build/ ninja -C build/ sudo ninja -C build/ install ``` -------------------------------- ### Launch sway with ConsoleKit2 and DBus Source: https://github.com/swaywm/sway/wiki/Home Use this command to start sway when not using logind but still needing DBus/PolKit/power management. It launches a ConsoleKit2 session and DBus with sway. You can omit the `ck-launch-session` part if desired. ```sh exec ck-launch-session dbus-launch --sh-syntax --exit-with-session sway ``` -------------------------------- ### Load a modified custom xkb keymap (xmodmap equivalent) Source: https://github.com/swaywm/sway/wiki/Home Override keymappings by specifying a custom xkb layout and options. The example uses a modified programmer Dvorak layout and sets caps lock to escape. ```sway input type:keyboard { # Modified programmer Dvorak. File at ~/.xkb/symbols/dvp_alt_gr_remapped_to_super xkb_layout "dvp_alt_gr_remapped_to_super" # Capslock key should work as escape key # See /usr/share/X11/xkb/rules/xorg.lst for options xkb_options caps:escape repeat_delay 250 repeat_rate 45 } ``` ```xkb default partial alphanumeric_keys xkb_symbols "basic" { include "us(dvp)" name[Group1] = "Modified programmer Dvorak"; key { [ Super_L, Super_R ] }; }; ``` -------------------------------- ### Load Xresources in Sway config Source: https://github.com/swaywm/sway/wiki/Home Add this line to the Sway config to load ~/.Xresources on startup, applying the Xft.dpi setting. ```sh exec xrdb -load ~/.Xresources ``` -------------------------------- ### Use wmname to fix Java application issues Source: https://github.com/swaywm/sway/wiki/Home Run wmname LG3D to fix blank windows and menus drawn at wrong offsets. If you get 'cannot open display', set DISPLAY=:0 first. ```shell wmname LG3D ``` -------------------------------- ### Enable udevmon service Source: https://github.com/swaywm/sway/wiki/Tricks Enable the udevmon service to start at boot. ```bash sudo systemctl enable udevmon.service ``` -------------------------------- ### Create sway-src directory Source: https://github.com/swaywm/sway/wiki/Debian-10-(Buster)-Installation Creates a directory to organize source code for building Sway 1.4. ```bash mkdir ~/sway-src ``` -------------------------------- ### Install Fedora build dependencies with dnf Source: https://github.com/swaywm/sway/wiki/Development-Setup Installs all required dependencies for building sway on Fedora. Dependencies must be installed one-by-one; outdated dependencies should be built as subprojects. ```sh dnf install -y git gcc meson ninja-build wayland-devel mesa-libEGL-devel mesa-libGLES-devel mesa-dri-drivers xorg-x11-server-Xwayland libdrm-devel libgbm-devel libxkbcommon-devel libudev-devel pixman-devel libinput-devel libevdev-devel systemd-devel cairo-devel libpcap-devel json-c-devel pam-devel pango-devel pcre-devel gdk-pixbuf2-devel hwdata-devel ``` -------------------------------- ### Set default DRM device with WLR_DRM_DEVICES Source: https://github.com/swaywm/sway/wiki/Home Set the WLR_DRM_DEVICES environment variable before starting sway to select a specific graphics card from /dev/dri/. Useful when wlroots picks the wrong card, e.g., in multi-GPU setups. ```sh WLR_DRM_DEVICES=/dev/dri/card1 sway ``` -------------------------------- ### Add library paths to LD_LIBRARY_PATH in ~/.profile Source: https://github.com/swaywm/sway/wiki/Development-Setup Add these lines to ~/.profile if `echo $LD_LIBRARY_PATH` does not include `/usr/local/lib/` and `/usr/local/lib64/`. After editing, run `source ~/.profile` to apply them. ```sh export LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=/usr/local/lib64/:$LD_LIBRARY_PATH ``` -------------------------------- ### Get sway version with sway -v Source: https://github.com/swaywm/sway/wiki/Home Fallback command to obtain the sway version when `swaymsg -t get_version` does not work. ```shell sway -v ``` -------------------------------- ### Load custom xkb keymap file Source: https://github.com/swaywm/sway/wiki/Home Load a custom xkb keymap file using the `xkb_file` option. The file path is relative to the user's home directory. ```sway # or input input "type:keyboard" { xkb_file ~/.config/xkb/custom } ``` -------------------------------- ### Start udevmon service Source: https://github.com/swaywm/sway/wiki/Tricks Start the udevmon service immediately to apply the space-to-mod mapping. ```bash sudo systemctl start udevmon ``` -------------------------------- ### Add /usr/local/bin to PATH in ~/.profile Source: https://github.com/swaywm/sway/wiki/Development-Setup Add this line to ~/.profile if `echo $PATH` does not include `/usr/local/bin`. After editing, run `source ~/.profile` to apply it to the current terminal session. ```sh export PATH=/usr/local/bin:$PATH ``` -------------------------------- ### Add swaybar, swaymsg, and swaynag to PATH Source: https://github.com/swaywm/sway/wiki/Development-Setup Populates PATH with the build outputs of swaybar, swaymsg, and swaynag for testing changes without installing Sway. Alternatively, set swaybar_command, swaynag_command, or swaybar_command in your config with custom executable paths. ```sh export PATH=build/swaybar:build/swaymsg:build/swaynag:$PATH ``` -------------------------------- ### Install Debian build dependencies with apt build-dep Source: https://github.com/swaywm/sway/wiki/Development-Setup Installs packages required to build sway on Debian-based distributions. The first command uses apt build-dep to install most dependencies, followed by a manual install of additional packages. ```sh apt build-dep sway ``` ```sh apt install glslang-tools libcairo2-dev libcap-dev libdbus-1-dev libdisplay-info-dev libevdev-dev libgdk-pixbuf2.0-dev libinput-dev libjson-c-dev libliftoff-dev libpam0g-dev libpango1.0-dev libpcre2-dev libpixman-1-dev libseat-dev libsystemd-dev libvulkan-dev libwayland-dev libwayland-egl1 libwlroots-dev libxcb-ewmh-dev libxkbcommon-dev meson pkgconf scdoc tree wayland-protocols ``` -------------------------------- ### Set default target to multi-user.target Source: https://github.com/swaywm/sway/wiki/Debian-10-(Buster)-Installation Changes the default systemd target to multi-user.target, which will prompt for login at a tty instead of starting the graphical environment. ```bash systemctl set-default multi-user.target ``` -------------------------------- ### Get sway version with swaymsg Source: https://github.com/swaywm/sway/wiki/Home Use this command to obtain the sway version when reporting issues. If it fails, use `sway -v` instead. ```shell swaymsg -t get_version ``` -------------------------------- ### Run JetBrains IDE with a different JRE Source: https://github.com/swaywm/sway/wiki/Home Invoke the IDE with STUDIO_JDK set to a compatible JRE path. For Sway 1.4 or earlier, also upgrade to Sway/wlroots master. ```shell STUDIO_JDK=/usr/lib/jvm/java-11-openjdk-amd64/ /opt/android-studio/bin/studio.sh ``` -------------------------------- ### Auto-start Sway with dbus-run-session Source: https://github.com/swaywm/sway/wiki/Home Starts Sway within a dbus session to address missing $DBUS_SESSION_BUS_ADDRESS issues. Use this variant if you encounter dbus-related problems. ```bash # If running from tty1 start sway [ "$(tty)" = "/dev/tty1" ] && exec dbus-run-session sway ``` -------------------------------- ### Disable client-side Qt decorations Source: https://github.com/swaywm/sway/wiki/Home Set QT_QPA_PLATFORM=wayland to use the Wayland backend and QT_WAYLAND_DISABLE_WINDOWDECORATION="1" to disable client-side decorations. ```shell QT_QPA_PLATFORM=wayland QT_WAYLAND_DISABLE_WINDOWDECORATION="1" ``` -------------------------------- ### Enable Fedora Sway Rolling Module and Install Source: https://github.com/swaywm/sway/wiki/Unsupported-packages To get a newer version of sway on Fedora, enable the sway rolling module first, then install sway. ```bash sudo dnf module enable sway:rolling sudo dnf install sway ``` -------------------------------- ### Example of Sway style in wlr_backend_autocreate Source: https://github.com/swaywm/sway/blob/master/CONTRIBUTING.md A complete example demonstrating the style guidelines, including function naming, error handling with goto, and use of wlr_log for errors. Shows the expected structure for construction/destruction functions. ```c struct wlr_backend *wlr_backend_autocreate(struct wl_display *display) { struct wlr_backend *backend; if (getenv("WAYLAND_DISPLAY") || getenv("_WAYLAND_DISPLAY")) { backend = attempt_wl_backend(display); if (backend) { return backend; } } const char *x11_display = getenv("DISPLAY"); if (x11_display) { return wlr_x11_backend_create(display, x11_display); } // Attempt DRM+libinput struct wlr_session *session = wlr_session_create(display); if (!session) { wlr_log(WLR_ERROR, "Failed to start a DRM session"); return NULL; } int gpu = wlr_session_find_gpu(session); if (gpu == -1) { wlr_log(WLR_ERROR, "Failed to open DRM device"); goto error_session; } backend = wlr_multi_backend_create(session); if (!backend) { goto error_gpu; } struct wlr_backend *libinput = wlr_libinput_backend_create(display, session); if (!libinput) { goto error_multi; } struct wlr_backend *drm = wlr_drm_backend_create(display, session, gpu); if (!drm) { goto error_libinput; } wlr_multi_backend_add(backend, libinput); wlr_multi_backend_add(backend, drm); return backend; error_libinput: wlr_backend_destroy(libinput); error_multi: wlr_backend_destroy(backend); error_gpu: wlr_session_close_file(session, gpu); error_session: wlr_session_destroy(session); return NULL; } ``` -------------------------------- ### Focus output on launch Source: https://github.com/swaywm/sway/wiki/Home Adds a focus output command to the sway config to set the initial monitor focus on launch. ```config focus output ``` -------------------------------- ### Add bar section to Sway config Source: https://github.com/swaywm/sway/wiki/Home Swaybar is configured similarly to i3bar by adding a `bar` section to the config. The example shows the basic structure with a comment placeholder. See `man 5 sway-bar` for the full list of options. ```config bar { # ...bar options.. } ``` -------------------------------- ### Auto-start sway on tty1 via .bash_profile Source: https://github.com/swaywm/sway/wiki/Debian-10-(Buster)-Installation Adds a check to .bash_profile to automatically execute sway when logging in on /dev/tty1 and no display is set. ```bash if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then exec sway fi ``` -------------------------------- ### Apply i3-dmenu-desktop patch manually Source: https://github.com/swaywm/sway/wiki/Home Download and apply the patch for i3-dmenu-desktop from i3 PR #2265. Requires sudo and the patch file in the current directory. ```shell wget 'https://patch-diff.githubusercontent.com/raw/i3/i3/pull/2265.patch' sudo patch -p0 /usr/bin/i3-dmenu-desktop < 2265.patch ``` -------------------------------- ### Enable contrib and non-free apt repositories Source: https://github.com/swaywm/sway/wiki/Debian-10-(Buster)-Installation Modifies /etc/apt/sources.list to add contrib and non-free components, required for building Sway 1.4 from source. ```bash sudo sed -i -e 's/main$/main contrib non-free/g' /etc/apt/sources.list ``` -------------------------------- ### Add pkgconfig paths to PKG_CONFIG_PATH in ~/.profile Source: https://github.com/swaywm/sway/wiki/Development-Setup Add these lines to ~/.profile if `echo $PKG_CONFIG_PATH` does not include `/usr/local/lib/pkgconfig`, `/usr/local/lib64/pkgconfig`, and `/usr/local/share/pkgconfig`. After editing, run `source ~/.profile` to apply them. ```sh export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig:$PKG_CONFIG_PATH export PKG_CONFIG_PATH=/usr/local/share/pkgconfig:$PKG_CONFIG_PATH ``` -------------------------------- ### sway-service.sh startup script Source: https://github.com/swaywm/sway/wiki/systemd-integration Place this script on your PATH (e.g., `/usr/local/bin/sway-service.sh`) to import environment variables from the login manager and start the sway service. It is executed by the desktop entry above. ```sh #! /bin/sh # first import environment variables from the login manager systemctl --user import-environment # then start the service exec systemctl --wait --user start sway.service ``` -------------------------------- ### Windows/KDE/gnome launcher shortcut Source: https://github.com/swaywm/sway/wiki/Home Toggle a launcher on a single keypress using Super_L, but only if no keybind was triggered with that key. Uses --no-repeat and --release flags to avoid conflicts. ```sway config bindsym --no-repeat --release Super_L exec pkill $launcher || $launcher ``` -------------------------------- ### Install Sway from Fedora Official Repositories (dnf install sway) Source: https://github.com/swaywm/sway/wiki/Unsupported-packages Sway is available in the official Fedora repositories. Run this command to install it. ```bash sudo dnf install sway ``` -------------------------------- ### Udev rule to create symlinks for DRM cards Source: https://github.com/swaywm/sway/wiki/Home Create /etc/udev/rules.d/set-dri-links.rules to symlink DRM cards by vendor/device IDs, useful when card paths are inconsistent (e.g., eGPUs). Get ATTRS values from udevadm info. ```udev KERNEL=="card*", SUBSYSTEM=="drm", ATTRS{vendor}=="0x1002", ATTRS{device}=="0x747e", SYMLINK+="dri/by-name/egpu" KERNEL=="card*", SUBSYSTEM=="drm", ATTRS{vendor}=="0x1002", ATTRS{device}=="0x1681", SYMLINK+="dri/by-name/igpu" ``` -------------------------------- ### List graphical.target dependencies Source: https://github.com/swaywm/sway/wiki/Debian-10-(Buster)-Installation Shows the dependency tree for graphical.target. Only items that are children of multi-user.target will remain active after switching targets. ```bash $ systemctl list-dependencies graphical.target graphical.target ● ├─accounts-daemon.service ... ● └─multi-user.target ● ├─anacron.service ... ● ├─basic.target ● │ ├─-.mount ... ``` -------------------------------- ### DRI3 not available error Source: https://github.com/swaywm/sway/wiki/Home Another common error message when hardware acceleration fails after Sway 1.10. ```text DRI3 not available ``` -------------------------------- ### Set environment variables for Android Studio and Gradle Source: https://github.com/swaywm/sway/wiki/Home Use these exports to fix Android Studio menu positioning issues in Sway. Adjust the JDK paths to valid locations on your system. ```sh # For Android Studio export _JAVA_AWT_WM_NONREPARENTING=1 export STUDIO_JDK=/usr/lib/jvm/java-14-openjdk # For Gradle export JAVA_HOME=/usr/lib/jvm/java-8-openjdk ``` -------------------------------- ### Update apt cache Source: https://github.com/swaywm/sway/wiki/Debian-10-(Buster)-Installation Refreshes the package index after enabling contrib and non-free repositories. ```bash sudo apt update ``` -------------------------------- ### Use symlinked DRM devices with WLR_DRM_DEVICES Source: https://github.com/swaywm/sway/wiki/Home Set WLR_DRM_DEVICES to the symlinked paths created by the udev rule, avoiding the delimiter issue in /dev/dri/by-path. ```sh WLR_DRM_DEVICES=/dev/dri/by-name/egpu:/dev/dri/by-name/igpu ``` -------------------------------- ### Memorize and switch target windows Source: https://github.com/swaywm/sway/wiki/Home Configuration to mark windows with numbers and switch focus to them using modes. Press $mod+ctrl+t to enter set mode and assign marks, then $mod+t to enter switch mode and focus marked windows. Includes default and escape bindings to exit modes. ```sway config # window switch setting set $mode_set_switch_window "set_switch_window: [0]-[9]" mode $mode_set_switch_window { bindsym 1 mark 1; mode "default" bindsym 2 mark 2; mode "default" bindsym 3 mark 3; mode "default" bindsym 4 mark 4; mode "default" bindsym 5 mark 5; mode "default" bindsym 6 mark 6; mode "default" bindsym 7 mark 7; mode "default" bindsym 8 mark 8; mode "default" bindsym 9 mark 9; mode "default" bindsym 0 mark 0; mode "default" bindsym Return mode "default" bindsym Escape mode "default" } bindsym $mod+ctrl+t mode $mode_set_switch_window set $mode_switch_window "switch_window: [0]-[9]" mode $mode_switch_window { bindsym 1 [con_mark="1"] focus; mode "default" bindsym 2 [con_mark="2"] focus; mode "default" bindsym 3 [con_mark="3"] focus; mode "default" bindsym 4 [con_mark="4"] focus; mode "default" bindsym 5 [con_mark="5"] focus; mode "default" bindsym 6 [con_mark="6"] focus; mode "default" bindsym 7 [con_mark="7"] focus; mode "default" bindsym 8 [con_mark="8"] focus; mode "default" bindsym 9 [con_mark="9"] focus; mode "default" bindsym 0 [con_mark="0"] focus; mode "default" bindsym t mode $mode_set_switch_window bindsym Return mode "default" bindsym Escape mode "default" } bindsym $mod+t mode $mode_switch_window ``` -------------------------------- ### Install Sway from Unofficial Nightly Repository for Debian 10 (buster) Source: https://github.com/swaywm/sway/wiki/Unsupported-packages Adds the quantum2.xyz sway-utils repository, which provides nightly builds of sway and wlroots compatible with Debian 10 (buster). Run these commands in order to install Sway from the repository. ```bash curl https://quantum2.xyz/apt.key | sudo apt-key add - echo 'deb [arch=amd64] https://apt.quantum2.xyz/sway-utils/ buster main' | sudo tee /etc/apt/sources.list.d/sway-utils.list sudo apt update sudo apt install sway ``` -------------------------------- ### Input device configuration block Source: https://github.com/swaywm/sway/wiki/Home Use the identifier from `swaymsg -t get_inputs` to configure a specific input device. The block can contain various input options. ```sway input { # ...config options... } ``` -------------------------------- ### Install space2meta plugin (AUR) Source: https://github.com/swaywm/sway/wiki/Tricks Install the space2meta plugin from the AUR, which is required for the space-to-mod key mapping. ```bash yay -S interception-space2meta ``` -------------------------------- ### Run polkit authentication agent in Sway config Source: https://github.com/swaywm/sway/wiki/Home Add this line to your Sway configuration to run the polkit-gnome authentication agent, which enables Polkit prompts for applications needing administrative permissions. ```config exec "/usr/libexec/polkit-gnome-authentication-agent-1" ``` -------------------------------- ### Install Sway from Unofficial Nightly Repository for Debian 11 (bullseye) Source: https://github.com/swaywm/sway/wiki/Unsupported-packages Adds the quantum2.xyz sway-utils repository, which provides nightly builds of sway and wlroots for Debian 11 (bullseye). Run these commands in order to install Sway from the repository. ```bash curl https://quantum2.xyz/apt.key | sudo apt-key add - echo 'deb [arch=amd64] https://apt.quantum2.xyz/sway-utils/ bullseye main' | sudo tee /etc/apt/sources.list.d/sway-utils.list sudo apt update sudo apt install sway ``` -------------------------------- ### Bind keyboard volume keys with PulseAudio Source: https://github.com/swaywm/sway/wiki/Home Add these bindsym lines to your Sway configuration to control volume using PulseAudio commands. ```config bindsym --locked XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle bindsym --locked XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -5% bindsym --locked XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +5% bindsym --locked XF86AudioMicMute exec pactl set-source-mute @DEFAULT_SOURCE@ toggle ``` -------------------------------- ### Keyboard layout configuration Source: https://github.com/swaywm/sway/wiki/Home Set keyboard layout, variant, and options. Multiple options are separated by commas. See `man 7 xkeyboard-config` for available options. ```sway # or input input "type:keyboard" { xkb_layout us,de xkb_variant ,nodeadkeys xkb_options grp:alt_shift_toggle } ``` -------------------------------- ### Set Java AWT environment variable for sway Source: https://github.com/swaywm/sway/wiki/Home Append this snippet to ~/.profile to set _JAVA_AWT_WM_NONREPARENTING=1 when the session desktop is sway, fixing Java application issues. ```shell if [ "$XDG_SESSION_DESKTOP" = "sway" ] ; then # https://github.com/swaywm/sway/issues/595 export _JAVA_AWT_WM_NONREPARENTING=1 fi ``` -------------------------------- ### Run clamshell script on reload Source: https://github.com/swaywm/sway/wiki/Home Adds an exec_always line to the sway config to run the lid state script whenever Sway is reloaded. ```config exec_always /path/to/script.sh ``` -------------------------------- ### Install dual-function-keys plugin (AUR) Source: https://github.com/swaywm/sway/wiki/Tricks Alternative plugin for interception-tools that provides more configurable key behavior. Install from AUR if the default space2meta timing is not suitable. ```bash yay -S interception-dual-function-keys ``` -------------------------------- ### Generate sway debug log Source: https://github.com/swaywm/sway/wiki/Home Run sway with debug logging enabled, redirecting output to ~/sway.log. Reproduce the problem briefly, then exit sway and upload the log with your config when reporting issues. ```shell sway -d 2> ~/sway.log ``` -------------------------------- ### Desktop file for screenshot annotation with swappy Source: https://github.com/swaywm/sway/wiki/Tricks Install this .desktop file to ~/.local/share/applications/grimshot-swappy.desktop to add swappy actions for capturing the current window, output, selected window, or selected area. Use with rofi and -drun-show-actions to access the actions. Each action pipes the grimshot output to swappy for annotation. ```desktop [Desktop Entry] Name=Swappy GenericName=Annotation Tool GenericName[de]=Anmerkungswerkzeug GenericName[fr]="Outil d'annotat" GenericName[pt_BR]=Ferramenta de Anotação Comment=A Wayland native snapshot editing tool Comment[de]=Ein natives Wayland Bildschirmfoto-Bearbeitungswerkzeug Comment[fr]="Un outil d'édition de capture d'écran avec support natif pour Wayland" Comment[pt_BR]=Uma ferramenta de edição de snapshot nativa do Wayland TryExec=swappy Exec=swappy -f %F Terminal=false Type=Application Keywords=wayland;snapshot;annotation;editing; Icon=swappy Categories=Utility;Graphics;Annotation; StartupNotify=true MimeType=image/png;image/jpeg; Actions=current-window;current-output;select-window;select-area; [Desktop Action current-window] Name=Current Window Exec=sh -c 'grimshot save active - | swappy -f -' [Desktop Action current-output] Name=Current Output Exec=sh -c 'grimshot save output - | swappy -f -' [Desktop Action select-window] Name=Select Window Exec=sh -c 'grimshot save window - | swappy -f -' [Desktop Action select-area] Name=Select Area Exec=sh -c 'grimshot save area - | swappy -f -' ``` -------------------------------- ### Start a program on a specific workspace with swaymsg Source: https://github.com/swaywm/sway/wiki/Tricks Switches to the 'test' workspace, launches gnome-calculator, then returns to the previous workspace. Works as long as sway can match the PID of the new window to the exec'd command or its children. ```bash swaymsg 'workspace test; exec gnome-calculator; workspace back_and_forth' ``` -------------------------------- ### Install Sway from Debian Official Repository (apt install sway) Source: https://github.com/swaywm/sway/wiki/Unsupported-packages For Debian 11 (bullseye) and later, an older version of sway (1.5 at time of writing) is available in the official repositories. Run this command to install it. ```bash sudo apt install sway ``` -------------------------------- ### Keyboard repeat delay and rate Source: https://github.com/swaywm/sway/wiki/Home Set the repeat delay and rate for keyboard input. The values are in milliseconds and repeats per second, respectively. ```sway # or input input "type:keyboard" { repeat_delay 500 repeat_rate 5 } ``` -------------------------------- ### Force monitor detection via sysfs status Source: https://github.com/swaywm/sway/wiki/Home Use this command to manually trigger hotplug detection for a monitor that isn't recognized. Replace `card0` and `DP-1` with your GPU and connector. Requires sudo. ```bash echo detect | sudo tee /sys/class/drm/card0-DP-1/status ``` -------------------------------- ### Wayland session desktop entry for sway service Source: https://github.com/swaywm/sway/wiki/systemd-integration Create this desktop entry at `/usr/share/wayland-sessions/sway-session.desktop` to let your login manager start sway via systemd instead of directly. It launches `sway-service.sh`. ```ini [Desktop Entry] Name=Sway Service Comment=SirCmpwn's Wayland window manager as a systemd service Exec=sway-service.sh Type=Application ``` -------------------------------- ### Install Sway on Arch Linux (pacman -S sway) Source: https://github.com/swaywm/sway/wiki/Unsupported-packages To install sway on Arch Linux, run this command. ```bash sudo pacman -S sway ``` -------------------------------- ### Disable display manager via systemctl Source: https://github.com/swaywm/sway/wiki/Debian-10-(Buster)-Installation Prevents the display manager from starting on boot. Replace gdm3.service with your actual display manager service name. ```bash sudo systemctl disable gdm3.service ``` -------------------------------- ### Show Xwayland shell in window title Source: https://github.com/swaywm/sway/wiki/Home Add this for_window rule to your Sway config to display the shell (Xwayland vs native) in window titles, helping identify Xwayland apps. ```sh for_window [shell=".*"] title_format "%title :: %shell" ``` -------------------------------- ### Libinput config options Source: https://github.com/swaywm/sway/wiki/Home Configure libinput options for a device, such as left-handed mode, tap-to-click, natural scrolling, and mouse acceleration. See `man 5 sway-input` for all options. ```sway input { left_handed enabled tap enabled natural_scroll disabled dwt enabled accel_profile "flat" # disable mouse acceleration (enabled by default; to set it manually, use "adaptive" instead of "flat") pointer_accel 0.5 # set mouse sensitivity (between -1 and 1) } ``` -------------------------------- ### Import sway environment variables into systemd user environment Source: https://github.com/swaywm/sway/wiki/Home Exports essential Wayland and sway variables (WAYLAND_DISPLAY, DISPLAY, XDG_CURRENT_DESKTOP, SWAYSOCK, I3SOCK, XCURSOR_SIZE, XCURSOR_THEME) from the running sway process into the systemd user environment. Place this exec line in sway's configuration; with dbus-broker this is sufficient. ```sway config exec systemctl --user import-environment WAYLAND_DISPLAY DISPLAY XDG_CURRENT_DESKTOP SWAYSOCK I3SOCK XCURSOR_SIZE XCURSOR_THEME ``` -------------------------------- ### Waybar service unit (waybar.service) Source: https://github.com/swaywm/sway/wiki/systemd-integration Starts Waybar as part of the sway session and stops it when graphical-session.target stops. Place it at ~/.config/systemd/user/waybar.service or /etc/systemd/user/waybar.service. Enable and start with `systemctl --user enable --now waybar`. To start for any graphical session, replace `WantedBy=sway-session.target` with `WantedBy=graphical-session.target`. ```ini # ~/.config/systemd/user/waybar.service or /etc/systemd/user/waybar.service [Unit] Description=Highly customizable Wayland bar for Sway and Wlroots based compositors. Documentation=https://github.com/Alexays/Waybar/wiki/ PartOf=graphical-session.target [Service] Type=simple ExecStart=/usr/bin/waybar [Install] WantedBy=sway-session.target ``` -------------------------------- ### urxvt transparency settings in .Xresources Source: https://github.com/swaywm/sway/wiki/Home Add these lines to your `.Xresources` file and reload with `xrdb ~/.Xresources` to enable real transparency for urxvt. Note that this conflicts with `URxvt.reversevideo`; if reversevideo is enabled, the text becomes transparent instead of the background. ```plaintext URxvt*depth: 32 URxvt*background: rgba:0000/0000/0200/c800 ``` -------------------------------- ### Automate xdotool window moves for two outputs Source: https://github.com/swaywm/sway/wiki/Multihead-setup-with-X11-backend Bash script automating steps 3 and 4 for two outputs with a width of 1920 pixels. It finds the X11 window IDs for sway outputs named 'wlroots - X11-1' and 'wlroots - X11-2', then moves them to the correct positions on the X11 screen. Requires xdotool and DISPLAY set to the X11 display. ```bash #!/bin/bash windows=$(DISPLAY=:0 xdotool search --name '') win1='' win2='' for win in $windows do name=$(DISPLAY=:0 xdotool getwindowname $win) if [[ $name == "wlroots - X11-1" ]] then win1=$win elif [[ $name == "wlroots - X11-2" ]] then win2=$win fi done DISPLAY=:0 xdotool windowmove $win1 1920 0 DISPLAY=:0 xdotool windowmove $win2 0 0 ``` -------------------------------- ### Multihead output configuration Source: https://github.com/swaywm/sway/wiki/Home Two output commands placed in the config file to arrange monitors side by side, with HDMI1 at 1920x1080 and eDP1 at 1600x900 positioned to the right. ```config output HDMI1 resolution 1920x1080 position 0 0 output eDP1 resolution 1600x900 position 1920 0 ``` -------------------------------- ### Move all workspace windows to a selected workspace Source: https://github.com/swaywm/sway/wiki/Home Defines a sway mode that moves all windows from every workspace to a chosen workspace (1-10) and switches to it. Triggered with $mod+shift+ctrl+m; press Return or Escape to exit the mode without moving. ```sway config set $mode_move_all_workspace_windows "Move all workspace windows to [0-9]?" mode $mode_move_all_workspace_windows { bindsym 1 [workspace=".*"] move to workspace 1; workspace number 1, mode "default" bindsym 2 [workspace=".*"] move to workspace 2; workspace number 2, mode "default" bindsym 3 [workspace=".*"] move to workspace 3; workspace number 3, mode "default" bindsym 4 [workspace=".*"] move to workspace 4; workspace number 4, mode "default" bindsym 5 [workspace=".*"] move to workspace 5; workspace number 5, mode "default" bindsym 6 [workspace=".*"] move to workspace 6; workspace number 6, mode "default" bindsym 7 [workspace=".*"] move to workspace 7; workspace number 7, mode "default" bindsym 8 [workspace=".*"] move to workspace 8; workspace number 8, mode "default" bindsym 9 [workspace=".*"] move to workspace 9; workspace number 9, mode "default" bindsym 0 [workspace=".*"] move to workspace 10; workspace number 10, mode "default" # back to normal: Enter or Escape bindsym Return mode "default" bindsym Escape mode "default" } bindsym $mod+shift+ctrl+m mode $mode_move_all_workspace_windows ``` -------------------------------- ### Vulkan DRI3 error message Source: https://github.com/swaywm/sway/wiki/Home Typical error when hardware acceleration fails after Sway 1.10 due to removed `wl_drm` support. Indicates missing DRI3 support. ```text vulkan: No DRI3 support detected - required for presentation Note: you can probably enable DRI3 in your Xorg config ``` -------------------------------- ### Update classic dbus activation environment with sway variables Source: https://github.com/swaywm/sway/wiki/Home For systems using the classic dbus implementation (not dbus-broker), updates dbus's separate activation environment with the same essential variables. Add this exec line to sway's configuration after the systemd import. ```sway config exec dbus-update-activation-environment WAYLAND_DISPLAY DISPLAY XDG_CURRENT_DESKTOP SWAYSOCK I3SOCK XCURSOR_SIZE XCURSOR_THEME ``` -------------------------------- ### Sway clipboard setup with wl-paste and clipman Source: https://github.com/swaywm/sway/wiki/Tricks Configure sway clipboard management using wl-paste and clipman. Two wl-paste processes watch the primary and normal clipboards, storing clippings with clipman. Keybindings are provided to pick, clear, remove, and empty clippings using rofi and wl-copy. ```sway config # There are two wl-paste processes running, one for the primary and one for the normal clipboard exec wl-paste -t text --watch clipman store exec wl-paste -p -t text --watch clipman store # The keybind to select a clipping bindsym $mod+y exec clipman --primary pick --tool rofi # Clear all clippings bindsym $mod+Shift+y exec clipman clear -a # Remove a selected clipping bindsym $mod+Mod1+y exec clipman clear --tool rofi # Empty the current clipping bindsym $mod+Ctrl+y exec : | wl-copy -p ``` -------------------------------- ### Clamshell mode bindswitch configuration Source: https://github.com/swaywm/sway/wiki/Home Uses bindswitch events to disable or enable the laptop output when the lid is closed or opened, with --reload and --locked flags. ```config set $laptop bindswitch --reload --locked lid:on output $laptop disable bindswitch --reload --locked lid:off output $laptop enable ``` -------------------------------- ### Build missing dependencies as subprojects Source: https://github.com/swaywm/sway/wiki/Development-Setup Clones additional Wayland and graphics dependencies as subprojects when your distribution does not ship new enough versions. The wlroots CI ensures builds on Arch Linux, Alpine edge, and FreeBSD. ```sh git clone https://gitlab.freedesktop.org/wayland/wayland.git subprojects/wayland git clone https://gitlab.freedesktop.org/wayland/wayland-protocols.git subprojects/wayland-protocols git clone https://gitlab.freedesktop.org/emersion/libdisplay-info.git subprojects/libdisplay-info git clone https://gitlab.freedesktop.org/emersion/libliftoff.git subprojects/libliftoff git clone https://gitlab.freedesktop.org/mesa/drm.git subprojects/libdrm git clone https://git.sr.ht/~kennylevinsen/seatd subprojects/seatd ``` -------------------------------- ### Move workspace to current output when switching Source: https://github.com/swaywm/sway/wiki/Home Replace $mod+ bindings to move the workspace to the current output when switching to it, instead of being refocused to a different output. Use this line for each workspace number. ```sway config bindsym $mod+1 [workspace="^1$"] move workspace to output current; workspace number 1 ``` -------------------------------- ### Run Flatpak App with Wayland Socket Source: https://github.com/swaywm/sway/wiki/Running-programs-natively-under-Wayland Runs a Flatpak app with the Wayland socket. Use --user for user installation. ```shell flatpak [--user] run --socket=wayland your-app ```