Table of Contents
What is this about?
sway is a tiling window manager, active project, working on Wayland. Modelled after i3 which runs on Xorg. Sway was just the right thing for me coming from Window Maker, which seems to stay on Xorg forever. Phoronix sees gnome/Wayland consuming less power than gnome/Xorg.
Running Sway on Fedora
Setup sway on Fedora instructions - my notes below should cover most of that.
# I did a LXDE-desktop installation of Fedora, and then: dnf -y install sway sddm for i in lxdm kdm gdm lightdm xdm; do systemctl disable $i done systemctl enable sddm systemctl set-default graphical.target reboot # After this, sddm starts and allows to directly run sway
Configuration and first steps
After you got sway running, it's time to familiarize yourself with the keyboard shortcuts and modify the configuration. The default config can be seen at https://github.com/swaywm/sway/blob/master/config.in or in file /etc/sway/config . The config file teaches you all shortcuts you need at this moment.
On my thinkpad, the english keyboard layout was configured by default. The $mod-key is the windows-key, which is on Linux not used anyway. Sway uses that key heavily. For the start, you should use the config suggested by Sway, and can then adapt it to your needs.
Custom config file
The default config is /etc/sway/config. If you want to customize, do this:
mkdir ~/.config/sway cp /etc/sway/config ~/.config/sway vi ~/.config/sway
Terminal settings
Status of various terminals on Fedora, with sway and for my needs:
- xterm:
- works, including input-method support via fcitx (so I can input Japanese)
- automatic url selection works, so double-clicking a URL in a terminal selects it. Yet, opening that directly in the browser does not work for me.
- increasing font with the keyboard works with extra config, but I need to find a good font for the different sizes
- terminator:
- works, including input-method support via fctx5 (so I can input Japanese)
- automatic url selection works nicely (doubleclicking a url)
- increasing font with the keyboard works out of the box, with German keyboard layout: <crtl>+<+>, <crtl>+<->
- alacritty: works, but has no imsupport, so no Japanese input possible
- foot: works, but apparently no imsupport as of foot-1.9.1-1.fc35.x86_64
My terminal config:
$ grep term ~/.config/sway/config set $term /home/chris/bin/myterm.sh $ cat /home/chris/bin/myterm.sh xterm -en UTF-8 -fg white -bg black -fn \ -Misc-Fixed-Medium-R-Normal--18-120-100-100-C-90-ISO10646-1 +sb -e bash
Changing workspace
A workspace in Sway is what I called “virtual screen” in Window Maker. Regarding workspaces, I mostly go with the default config from Sway. I just added one detail: $mod+Left changes to the previous workspace, and $mod+Right to the next workspace. By default, one can with $mod+1 jump to the first workspace, with $mod+2 to the second workspace, and so on. So I added this in ~/.config/sway/config:
bindsym Ctrl+Left workspace prev # on default keyboards bindsym Ctrl+Right workspace next bindsym Hangul_Hanja+Left workspace prev # on the keyboard from Korea bindsym Hangul_Hanja+Right workspace next bindsym Prior workspace prev # Thinkpad keys above cursor keys bindsym Next workspace next
The last 2 lines are for the “right CTRL key” on this keyboard here which I bought in Korea. When running 'xev' and then pressing the key, one sees the identifier for the key, in my case 'Hangul_Hanja'.
Firefox notes
- If you simply hit <modkey>+<d> and then execute 'firefox', then you run firefox in Xorg compat mode. For native wayland mode, “MOZ_ENABLE_WAYLAND=1” has to be set in the environment. Having a file ~/bin/wfirefox which contains “env MOZ_ENABLE_WAYLAND=1 firefox” and then running 'wfirefox' runs firefox properly.
- In 2022, I encountered an issue where the mouse pointer changed for example to a magnifying glass, but then never changed back to the normal pointer. This turned out GDK related, starting firefox as follows fixes the issue: “env GDK_BACKEND=x11 MOZ_ENABLE_WAYLAND=0 firefox”
- Activate WebRender for performance reasons: https://wiki.archlinux.org/title/Firefox/Tweaks#Enable_WebRender_compositor
- tweaks for video performance: https://wiki.archlinux.org/title/Firefox#Hardware_video_acceleration
Locking the screen
I have a habit of locking the screen when leaving the workplace, by pressing F9. Easy to implement:
# install xlock dnf -y install xlockmore # add the config echo 'bindsym F9 exec /usr/bin/xlock -mode blank' >>~/.config/sway/config # reload config press <modkey> + <Shift> + <c> press F9 for testing
Controlling brightness
On laptops, package `light` should be installed, and this be added to ~/.config/sway/config:
bindsym $mod+F5 exec light -U 5 bindsym $mod+F6 exec light -A 5
With this, one can press $mod+F5/F6 to control brightness.
Internal/external screens
Using xrandr is not recommended, but so far the replacements actually look good. I frequently dock/undock my system. When docked, I only want to use an external screen.
# lets look at the names for our outputs swaymsg -t get_outputs Output DP-4 'Dell Inc. DELL U2412M RPT5T2372ADL' (focused) Current mode: 1920x1200 @ 59.950001 Hz [..] Output eDP-1 'Unknown 0x21ED 0x00000000' [..] # In the sway config, I refer to these entries. So I frequently # modify the config, then reload with <modkey>+<Shift>+<c>, and # have the new setup active. # in ~/.config/sway/config, for 'docked'config: output DP-4 enable output eDP-1 disable # in ~/.config/sway/config, for all monitors active: output DP-4 enable output eDP-1 enable
Custom statusbar
dnf install -y python3-psutil python3-netifaces fontawesome-fonts cd /opt git clone git://github.com/tobi-wan-kenobi/bumblebee-status # now modify the users ~/.config/sway/config, change status_command while date +'%Y-%m-%d %l:%M:%S %p'; do sleep 1; done into status_command /opt/bumblebee-status/bumblebee-status \ -m traffic cpu memory sensors2 battery weather datetimetz time \ -p cpu.format={:.00f}% \ traffic.exclude=virbr,lo,redhat,nebula traffic.showname=False \ traffic.format={:.0f} \ time.format="独 %H:%M" \ datetimetz.format="日本 %H:%M" datetimetz.timezone="Asia/Tokyo" \ memory.format="{used}" \ sensors2.showtemp=false sensors2.showcpu=false \ sensors2.field_exclude=fan2 \ traffic.interval=5s cpu.interval=5s sensors2.interval=5s \ memory.interval=1m weather.interval=30m battery.interval=1m \ -t powerline
Details: https://github.com/tobi-wan-kenobi/bumblebee-status
Japanese input: ibus
Until Fedora37/ibus-1.5.27, ibus did now work for me on sway/wayland (Fedora bugzilla against ibus.). From Fedora37 on it works.
dnf -y install ibus ibus-setup ibus-gtk3 ibus-wayland \ ibus-skk ibus-mozc ibus-kkc ibus-qt # run ibus-daemon at sway startup echo 'exec /usr/bin/ibus-daemon --xim --daemonize' \ >>~/.config/sway/config # set environment variables, i.e. in ~/.bashrc export IMSETTINGS_INTEGRATE_DESKTOP=yes export IMSETTINGS_MODULE=ibus export QT_IM_MODULE=ibus export XMODIFIERS=@im=ibus export GTK_IM_MODULE=ibus # then exit sway with <modkey>+<Shift>+<e> # and start sway again, then ibus-setup
Japanese input: fcitx5
Using fcitx5 at the moment, not ibus.
dnf -y install fcitx5-configtool fcitx5-kkc fcitx5-mozc # run fcitx at sway startup echo 'exec --no-startup-id fcitx5 -d' >>~/.config/sway/config # set environment variables, i.e. in ~/.bashrc export IMSETTINGS_INTEGRATE_DESKTOP=yes export IMSETTINGS_MODULE=fcitx export GTK_IM_MODULE=fcitx export QT_IM_MODULE=fcitx export XMODIFIERS=@im=fcitx # then exit sway with <modkey>+<Shift>+<e> # and start sway again, then imsettings-switch fcitx5 fcitx5-configtool
Screenshots
# As of Fedora37, grim is packaged. # If not packaged on your distro, build from https://github.com/emersion/grim sudo dnf install grim # lets take a screenshot grim screenshot.png # if error "failed to create display" env WAYLAND_DISPLAY='wayland-1' grim screenshot.png
Video chat Screen sharing
As of Fedora35, xdg-desktop-portal-wlr seems like the best way for screen sharing - but it requires to use a browser based videoconf software, does not work with the stand alone Skype program.
- Chromium might need this config change: open chrome://flags/#enable-webrtc-pipewire-capturer
- see also related blogposts from Jan, link
server software / service | client software | Way 1 (xdg) | Way 2 (video stream) | Way 3 (tabs) |
---|---|---|---|---|
Jitsi 2.0.6433-1@Debian Bullseye selfhosted | Firefox 94@Fedora35 | no | no | |
Jitsi 2.0.6433-1@Debian Bullseye selfhosted | Chrome 95@Fedora35 | yes | yes | |
Skype | skypeforlinux-8.77.0.97-1 | no | no | |
https://web.skype.com Nov-2021 | Firefox 94@Fedora35 | no | no | |
https://web.skype.com Nov-2021 | Chrome 95@Fedora35 | yes | yes (unsharp) | yes |
Bluejeans Nov-2021 | Firefox 94@Fedora35 | yes | yes (unsharp) | no |
Bluejeans Nov-2021 | Chrome 95@Fedora35 | yes | yes (unsharp) | yes |
google hangouts | Chrome 95@Fedora35 | yes | ||
google meet | Chrome 95@Fedora35 | yes |
Way 1: xdg-desktop-portal-wlr
- con: does not work with stand alone Skype application
- pro: low cpu load
sudo dnf -y install xdg-desktop-portal-wlr # add the following to ~/.config/sway/config exec dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway # then reload sway with <mod-key>+<shift>+<c>
Then access this URL, and click “screen capture” to test.
Way 2: full screen capture as video stream
From video: openSUSEway_is_a_full_Wayland_DE_based_on_Sway, this is recording the screen activity and making it available on a video device like /dev/video0. You can then feed that into Jitsi/bluejeans/skype. This workaround will transmit your normal desktop, but the constant recording causes quite some cpu load.
# install packages dnf install v4l2loopback wf-recorder wlr-randr \ akmod-v4l2loopback kmod-v4l2loopback # ensure module is loaded modprobe v4l2loopback # find out which device loopback uses, for next command v4l2-ctl --list-devices # start recording screen, using v4l2 loopback device wf-recorder --muxer=v4l2 --codec=rawvideo \ --file=/dev/video0 --pixel-format yuyv422 wlr-randr mplayer tv:// -tv driver=v4l2:device=/dev/video0
Way 3: container desktop in browser tab
webtops container. This runs a desktop in a container, and you can access that desktop in a browser tab, which you can for example share in google meet. This uses memory, but less cpu load than workaround 1.
podman run -d --name=webtop \ -e PUID=1000 -e PGID=1000 -e TZ=Asia/Tokyo -p 3000:3000 \ -v /home/chris/sync:/sync:Z,ro --shm-size="1gb" \ --restart unless-stopped ghcr.io/linuxserver/webtop:fedora-xfce
Further notes / links
- X11 apps forwarding via SSH: Logging into remote systems using i.e. 'ssh -Y rhel8u2b', and having on the remote system for example xauth and xterm installed, I can run xterm remotely and get it forwarded. $DISPLAY in the session is set to “localhost:10.0”.
- alacritty not working with fcitx5 for input method switching
WAYLAND_DISPLAY= alacritty
- or
WINIT_UNIX_BACKEND=x11 alacritty
- Hanging menu issue: I have experienced hanging menus: so after pressing $mod + D, the menu for running applications stays and can not be removed. In that case, “killall dmenu” removed the menu, and $mod + Shift + c can reload the normal top bar.
- Additional software: My reminder for additional software. All from Fedora or rpmfusion repos.
- firefox, google-chrome
- evince - pdf viewer
- mplayer, qiv - video, picture viewer
- wf-recorder - record screen. env WAYLAND_DISPLAY=wayland-1 wf-recorder -f out.mkv
- Links:
- Ducks wayland page: https://wiki.duckcorp.org/index.php/Using_Wayland
- Thomas Leister sway page, https://thomas-leister.de/en/sway-window-manager/
- example config file: https://gist.github.com/7415963987456321/809f04a30aac61ab12504d8aa0e2111f