SWAY Configuration
SWAY a tiling Wayland compositor
With the year holiday season, I found myself with the perfect
opportunity to tackle a long-awaited task: Migrating my i3
configuration to SWAY
.
With a bit of time to spare and the desire to explore and play with
Wayland, I decided to make the switch to the SWAY
compositor, a
Wayland alternative to my beloved i3
window manager.
To my pleasant surprise, the transition went quite smoothly, with only a few minor adjustments needed.
Application summary
- Base Distro: Debian
- Bar: swaybar
- Desktop notification: Dunst
- Network/Wifi mgmt: systemd/wpa_supplicant/wpa_gui
- Launcher: wmenu
- Lock screen: Swaylock
- Battery applet: i3status
- Screenshots: grim
- Brightness control: brightnessctl
- Sound/Volume control: Pavucontrol
- Bluetooth settings/applet: Blueman
- Terminal: foot
- File manager: Nautilus, Dired
- Mount unmount usb disks: udiskctl
~/.config/sway/config
# -*- mode:conf; -*-
# note: sway does not consider '--no-startup-id option'.
# https://github.com/swaywm/sway/blob/1211a81aad18bbc4d9e8fb9973238ad8e7e1f688/sway/commands/exec_always.c#L26
set $mod Mod4
font pango:Inconsolata 14
# 2024-Dec-22 swaymsg -t get_outputs
output eDP-1 scale 1
# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod
# start a terminal
set $term foot
bindsym $mod+Return exec $term
# kill focused window
bindsym $mod+Shift+q kill
# start dmenu (a program launcher)
set $menu dmenu_path | wmenu -f "Inconsolata 18" -p ">" | xargs swaymsg exec --
bindsym $mod+d exec $menu
# change focus
bindsym $mod+j focus left
bindsym $mod+k focus down
bindsym $mod+l focus up
bindsym $mod+semicolon focus right
# alternatively, you can use the cursor keys:
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right
# move focused window
bindsym $mod+Shift+j move left
bindsym $mod+Shift+k move down
bindsym $mod+Shift+l move up
bindsym $mod+Shift+semicolon move right
# alternatively, you can use the cursor keys:
bindsym $mod+Shift+Left move left
bindsym $mod+Shift+Down move down
bindsym $mod+Shift+Up move up
bindsym $mod+Shift+Right move right
# split in horizontal orientation
bindsym $mod+h split h
# split in vertical orientation
bindsym $mod+v split v
# enter fullscreen mode for the focused container
bindsym $mod+f fullscreen toggle
# 'fullscreen toggle global' will use all the screen. which is usefull for Citrix workspace.
# however it completely hides all the other workspaces
bindsym $mod+g fullscreen toggle global
# change container layout (stacked, tabbed, toggle split)
bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
#bindsym $mod+e layout toggle split
# toggle tiling / floating
bindsym $mod+Shift+space floating toggle
# change focus between tiling / floating windows
bindsym $mod+space focus mode_toggle
# focus the parent container
bindsym $mod+a focus parent
# focus the child container
#bindsym $mod+d focus child
bindsym $mod+Escape workspace back_and_forth
# work area numbers
set $workspace1 "1: "
set $workspace2 "2: "
set $workspace3 "3: "
set $workspace4 "4: "
set $workspace5 "5: "
set $workspace6 "6: "
set $workspace7 "7: "
set $workspace8 "8: "
set $workspace9 "9: "
set $workspace10 "10: "
# switch to workspace
bindsym $mod+1 workspace $workspace1
bindsym $mod+2 workspace $workspace2
bindsym $mod+3 workspace $workspace3
bindsym $mod+4 workspace $workspace4
bindsym $mod+5 workspace $workspace5
bindsym $mod+6 workspace $workspace6
bindsym $mod+7 workspace $workspace7
bindsym $mod+8 workspace $workspace8
bindsym $mod+9 workspace $workspace9
bindsym $mod+0 workspace $workspace10
# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace $workspace1
bindsym $mod+Shift+2 move container to workspace $workspace2
bindsym $mod+Shift+3 move container to workspace $workspace3
bindsym $mod+Shift+4 move container to workspace $workspace4
bindsym $mod+Shift+5 move container to workspace $workspace5
bindsym $mod+Shift+6 move container to workspace $workspace6
bindsym $mod+Shift+7 move container to workspace $workspace7
bindsym $mod+Shift+8 move container to workspace $workspace8
bindsym $mod+Shift+9 move container to workspace $workspace9
bindsym $mod+Shift+0 move container to workspace $workspace10
# reload the configuration file
bindsym $mod+Shift+c reload
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $mod+Shift+r restart
# exit Sway (logs you out of your wayland session)
bindsym $mod+Shift+e exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -b 'Yes, exit sway' 'swaymsg exit'
# resize window (you can also use the mouse for that)
mode "resize" {
# These bindings trigger as soon as you enter the resize mode
# Pressing left will shrink the window’s width.
# Pressing right will grow the window’s width.
# Pressing up will shrink the window’s height.
# Pressing down will grow the window’s height.
bindsym j resize shrink width 10 px or 10 ppt
bindsym k resize grow height 10 px or 10 ppt
bindsym l resize shrink height 10 px or 10 ppt
bindsym semicolon resize grow width 10 px or 10 ppt
# same bindings, but for the arrow keys
bindsym Left resize shrink width 10 px or 10 ppt
bindsym Down resize grow height 10 px or 10 ppt
bindsym Up resize shrink height 10 px or 10 ppt
bindsym Right resize grow width 10 px or 10 ppt
# back to normal: Enter or Escape
bindsym Return mode "default"
bindsym Escape mode "default"
}
# I never use resize and this is the same key binding as awesome-wm
# bindsym $mod+r mode "resize"
bindsym $mod+r exec $menu
set $bg-color #2f343f
set $inactive-bg-color #2f343f
set $active-bg-color #5f676a
set $text-color #f3f4f5
set $inactive-text-color #676E7D
set $urgent-bg-color #E53935
# window colors
# border background text indicator
client.focused $bg-color $bg-color $text-color #0000ff
client.unfocused $inactive-bg-color $inactive-bg-color $inactive-text-color #0000ff
client.focused_inactive $inactive-bg-color $inactive-bg-color $inactive-text-color #0000ff
client.urgent $urgent-bg-color $urgent-bg-color $text-color #0000ff
# Start swaybar to display a workspace bar
bar {
position top
tray_output eDP-1
status_command i3status
strip_workspace_numbers no
colors {
background $bg-color
separator #757575
# border background text
focused_workspace $bg-color $active-bg-color $text-color
active_workspace $inactive-bg-color $inactive-bg-color $inactive-text-color
inactive_workspace $inactive-bg-color $inactive-bg-color $inactive-text-color
urgent_workspace $urgent-bg-color $urgent-bg-color $text-color
}
}
# assign [class="Chromium"] $workspace2
assign [class="vlc"] $workspace5
# Lock screen. 'dpms' option will turn off all displays right after locking.
# Example configuration:
exec swayidle -w \
timeout 300 'swaylock -f -c 000000' \
timeout 600 'swaymsg "output * dpms off"' \
resume 'swaymsg "output * dpms on"'
bindsym $mod+Control+l exec swaylock -f -c 000000
# ensure the keyboard is in english-US international
input "type:keyboard" {
xkb_layout "us"
xkb_variant "intl"
xkb_options ctrl:nocaps
}
# Disable title bar
default_border pixel 1
default_floating_border pixel 1
# Running under XWayland:
# xprop tool can be used to get WM_CLASS, WM_NAME properties
for_window [class="Skype"] floating enable
for_window [class="(?i)Wfica"] floating enable
for_window [window_type="notification"] floating enable
# Running natively under Wayland:
for_window [title="(?:Open|Save) (?:File|Folder|As)"] floating enable
for_window [title="(?i)Call with "] floating enable
for_window [app_id="(?i)Gimp"] floating enable
# SUSPEND, HIBERNATE, see i3exit.sh script
set $mode_system System (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown
set $locker "swaylock -f -c 000000"
mode "$mode_system" {
bindsym e exec swaymsg exit
bindsym s exec "$locker && systemctl suspend"
bindsym h exec "$locker && systemctl hibernate"
bindsym r exec systemctl reboot
bindsym Shift+s exec systemctl poweroff
# back to normal: Enter or Escape
bindsym Return mode "default"
bindsym Escape mode "default"
}
bindsym XF86Tools mode "$mode_system"
bindsym $mod+e exec emacsclient -c
# saves screenshot in ~/Pictures
bindsym Print exec grimshot --notify savecopy area
#Brightness
bindsym XF86MonBrightnessUp exec brightnessctl set 5%+
bindsym XF86MonBrightnessDown exec brightnessctl set 5%-
#Volume Buttons
bindsym XF86AudioRaiseVolume exec amixer sset 'Master' 5%+ -q
bindsym XF86AudioLowerVolume exec amixer sset 'Master' 5%- -q
bindsym XF86AudioMute exec amixer sset 'Master' toggle
# Wallpaper
output "*" background ~/.config/sway/linuxv.png fill
#exec nm-applet
exec wpa_gui -t
exec blueman-applet
# load DBUS and specific config
include /etc/sway/config.d/*