[TRACKING] Sway / i3 WM on Framework

Thanks to Windows 11 giving me some some issues, I decided it was time to move back to Ubuntu LTS. Thank to @lightrush and his handy salt script I was able to get up and running in NO time. That is until I decided to give i3 and Sway a shot.

After getting them both configured I have to say that I love tiling managers. Installing them on top of Ubuntu is also great, because you have the flexibility to switch between them and use Gnome as well.

Sway works smoother and seems to use less resources, but i3 runs perfectly as well.

Getting i3 to lock automatically when suspending (via the lid switch) or hibernating is still a work in progress.

I’m also trying to figure out how to map the brightness function keys to a keybinding in either i3 or sway. It will be reliant on brightnessctl. I’d like to get all of the keyboard shortcuts working (transport controls for media, etc.) as well, but that isn’t crucial.

Any of our tiling manger professionals have some tips after getting it all set up on your Framework?

3 Likes

You can determine what the symbols are by running xev (or wev) and pressing the key. For example (I’m typing from my desktop, so I’ll use the media keys here), if I run wev and press the key that has a ‘stop’ icon on it (in this keyboard, that’s Fn+F10), I see that wev reports that the sym for that key is XF86AudioStop.

Once you obtain that sym, you can put something like bind XF86AudioStop exec mpc stop in your sway/i3 config and it should “just work”.

If you want, I’ll edit this post when I open up my Framework later and put the exact lines I have in my sway config for brightness and media keys.

1 Like

I use lollypop for the most part. Is there a way to make it app agnostic? Just issue a stop audio system wide?

I would be super grateful if you would do that!!!

You can probably use playerctl, assuming lollypop has support for MPRIS?

1 Like

I decided to make a new post.

I have the following lines in my ~/.config/sway/config:

bindsym XF86MonBrightnessDown exec brightnessctl -d intel_backlight s 10%-
bindsym XF86MonBrightnessUp exec brightnessctl -d intel_backlight s 10%+
bindsym XF86AudioPlay exec mpc toggle
bindsym XF86AudioNext exec mpc next
bindsym XF86AudioPrev exec mpc prev
bindsym XF86AudioLowerVolume exec pactl set-sink-volume 0 -10%
bindsym XF86AudioRaiseVolume exec pactl set-sink-volume 0 +10%
bindsym XF86AudioMute exec pactl set-sink-mute 0 toggle
bindsym Print exec grimshot --notify save active

Of course, you could change those mpc commands to equivalent commands with playerctl (i.e. playerctl play-pause, playerctl next, playerctl previous).

6 Likes

Any chance you are an expert at i3 xss-lock i3locking when the lid switch or hibernation take place? I got it working but with a white background. I’d like to set it black or use an image, but everytime I add those options in sway config is doesn’t work. It is always just a white background.

Any thoughts?

Thanks a ton for this! If I wasn’t having Workstation 3d acceleration issues I would probably not even be messing with i3. Very happy with Sway and Waybar.

1 Like

Sorry, I actually went from using awesome on X11 to using sway on Wayland since there wasn’t a real Wayland version/successor of awesome. Also, presumably you’d use swaylock with sway (not xss-lock and i3lock?), but that was probably a typo (the default sway config over at /etc/sway/config contains a snippet to automatically deal with screenlocking using swaylock).

No problem! I’m still somewhat new to sway and Wayland more generally, even if I’m pretty used to tiling WMs at this point (I’ve been using awesome for several years at this point).

Yeah, thank you! swaylock work SOOO much better than i3lock. It is basically un-comment a couple lines and it just works. So much easier, especially getting a specific image to be shown instead of just a color background.

But there is something about i3, that I also really like. I can’t put my finger on it. Maybe it is just the fact that Putty and VMware Workstation just work.

Personally, I setup a config file (in ~/.config/swaylock/config) so that I don’t have to edit the multiple places I have swaylock invocations in my sway config (I setup a keybinding to manually lock the screen i.e. bindsym $mod+l exec 'LANG=en_US.UTF8 swaylock' — the LANG=en_US.UTF8 is because my actual locale isn’t English, but swaylock isn’t localized so it just ends up not being able to display its messages :joy:).

1 Like

Yeah, I do the Mod + L for manual lock as well. What I meant by easier is that it is easier to configure. I was able to add a background to the lockscreen and set it to trigger from suspend and hibernate, with very little effort.

i3lock, by comparison, is still not working properly, and I can’t figure out why. I’ve got services files written in /etc/systemd/system etc, but no dice.

My last hurdle to using Sway in the long term is figuring out how to get Putty (which is dependent on X for tunneling) to work on Wayland.

Out of curiosity what is your native tongue?

Right. What I mean is that I don’t have to separately configure the swayidle command (which runs swaylock at preconfigured events) and the manual lock command, since everything is read from the config file. That’s just a personal preference, though, just to keep my sway config a bit more tidy.

Presumably it would be a user, not a system service? But yeah, as I said, I don’t have much experience with it (though I used to use slock with xss-lock, configured as a user systemd service, which worked fairly well).

It should work if you install Xwayland (you’ll have to restart sway afterwards to have it recognize that xwayland is installed).

I’m bilingual in both English and Kannada. I keep LANG=kn_IN.UTF8 set just to see how well (or poorly) programs are localized, and that’s how I realized that swaylock is completely English-specific xD

1 Like

Hopefully only for now. As it gains popularity maybe it will gain some translations.

Just wanted to thank you again, as I’ve been able to fix all of my issues with Workstation. All the shortcut function keys are properly mapped and functional.

It took a couple of days, but I’m very happy with this setup.

2 Likes

Yup! I might even look to get involved as a contributor if only so that I can have my lockscreen in Kannada :joy:

Glad to hear it! :blush:

1 Like

One quick thing I’ve found is that when rebooting your sink source can change. If you use
@DEFAULT_SINK@ instead of 0 (or any other number for that matter) you wont have issues upon reboot. Your volume keys should always just work. :+1:

3 Likes

Cool, thanks for the tip! :blush:

1 Like

I am using i3 window manager on Fedora 35. Though this thread is about Ubuntu. Maybe the content could be similar between Ubuntu and Fedora. So let me post here.

Based on this setting about Media keys: Sway / i3 WM on Framework - #6 by Chiraag_Nataraj and other comments, I created my own.

Note I checked each media key’s symbol by xev -event keyboard. For print screen key, I am using gnome-screenshot command as I also have Gnome environment. To use mpc, you need to install mpd from RPMFusion. I haven’t tested the mpc settings by myself.

# Media keys
# $ xev -event keyboard
# Use pactl.
# Framework Laptop F1: XF86AudioMute
bindsym XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle
bindsym XF86AudioMicMute exec pactl set-source-mute @DEFAULT_SOURCE@ toggle
# Framework Laptop F2: XF86AudioRaiseVolume
bindsym XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +10%
# Framework Laptop F3: XF86AudioLowerVolume
bindsym XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -10%
# Use mpc (Music Playing Client) and mpd (Music Playing Daemon) from RPM Fusion.
# https://fedoramagazine.org/playing-music-on-your-fedora-terminal-with-mpd-and-ncmpcpp/
# Framework Laptop F4: XF86AudioPrev
bindsym XF86AudioPrev exec mpc prev
# Framework Laptop F5: XF86AudioPlay
bindsym XF86AudioPlay exec mpc toggle
# Framework Laptop F6: XF86AudioNext
bindsym XF86AudioNext exec mpc next
# Framework Laptop F7: XF86MonBrightnessDown
# The --min-value option is important to prevent the complete darkness.
bindsym XF86MonBrightnessDown exec "brightnessctl --device intel_backlight --min-value=5 set 5%-"
# Framework Laptop F8: XF86MonBrightnessUp
bindsym XF86MonBrightnessUp exec "brightnessctl --device intel_backlight set 5%+"
# Framework Laptop F9: Super_L + p
# TODO: Assign this multiple screen key with the toggle multiple screens when using it.
# https://fedoramagazine.org/using-i3-with-multiple-monitors/
bindsym $mod+p exec firefox https://fedoramagazine.org/using-i3-with-multiple-monitors/
# Framework Laptop F10: XF86RFKill (already available)
# $ rfkill list all
# $ nmcli radio all
# Framework Laptop F11: Print
# https://unix.stackexchange.com/questions/497897/print-screen-key-in-i3
bindsym Print exec gnome-screenshot -i
# Framework Laptop F12: XF86AudioMedia
bindsym XF86AudioMedia exec firefox https://community.frame.work/
3 Likes

Seeing the GitHub repository of i3 and sway, sway has more stars than i3. But both seems well-maintained. I have been using i3 on my ThinkPad Carbon, and now customizing the i3 on my Framework Laptop.

This Youtube video Tiling Window Management and i3wm config additions introducing i3 is informative. It seems the person has long experience of window managers.

And he is sharing his heavily customized i3 config at his GitHub repository.

Here is how to see it. As he stopped supporting i3, you need to check a past commit.

$ git clone https://github.com/LukeSmithxyz/voidrice.git
$ cd voidrice
$ git checkout ad161d9363aadeb9f4ec3c852ca6c96162f2b4b0
$ vi .config/i3/config

This person’s Youtube play list about Minimalist software looks nice.

1 Like

My experience in general is that Sway works better than i3 on the Framework Laptop, but both work. I have noticed better performance on swap and zero tearing.

The cool thing about i3 and sway is that sway was designed to be a drop in replacement for it. It is i3 for Wayland basically. So your i3 config will work with Sway, with perhaps minimal updates.

2 Likes

Thanks for the info. After checking both sway and i3’s GitHub repositories and Wikipedia pages, sway is on Wayland and completely written in C. The performance might be better in C. And i3 is on X-Window system written in C + some script languages. And the Wayland looks more modern than X Window system. Maybe I will try sway.