Skip to content
Pavlo Rudy edited this page Nov 19, 2022 · 9 revisions

How to install software for Sway environment

sudo swupd 3rd-party bundle-add sway-extras \
alacritty kitty waybar

How to start Sway without session manager (gdm, lightdm, etc)

# /etc/systemd/user/sway.service

[Unit]
Description=sway - SirCmpwn's Wayland window manager
Documentation=man:sway(5)
BindsTo=default.target
Wants=default.target
After=default.target

[Install]
WantedBy=default.target

[Service]
Type=simple
EnvironmentFile=-%h/.config/sway/env
#ExecStartPre=systemctl --user unset-environment WAYLAND_DISPLAY DISPLAY # This line make you able to logout to dm and login into sway again
ExecStart=dbus-run-session sway
Restart=on-failure
RestartSec=1
TimeoutStopSec=10

Then enable the systemd service: systemctl --user enable sway.service && systemctl --user daemon-reload. Sway will start after next tty login.

Configuration

Sway configuration file located in ~/.config/sway/config.

Swaylock

Create the file to fix unlock.

Terminal emulator

set $term alacritty

Application launcher

set $menu rofi -show drun | xargs swaymsg exec --

set $menu bemenu | xargs swaymsg exec --

Disable borders

default_border none

wlsunset (redshift alternative)

exec_always "wlsunset -l 12.3 -L 45.6"

gnome-keyring

exec_always "dbus-update-activation-environment DISPLAY XAUTHORITY WAYLAND_DISPLAY && gnome-keyring-daemon --start --components=secrets"

Set the font and theme for GTK applications

set $gnome-schema org.gnome.desktop.interface
exec_always {
    gsettings set $gnome-schema gtk-theme 'theme name'
    gsettings set $gnome-schema icon-theme 'icon theme name'
    gsettings set $gnome-schema cursor-theme 'cursor theme name'
    gsettings set $gnome-schema font-name 'ClearSans 18'
}

Random wallpaper from ~/Pictures/Wallpapers

set $wallpapers_path $HOME/Pictures/Wallpapers
output * bg $(find $wallpapers_path -type f | shuf -n 1) fill

Idle configuration

 exec swayidle -w \
          timeout 300 'swaylock -f -c 000000' \
          timeout 600 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' \
          before-sleep 'swaylock -f -c 000000'

Input configuration

input type:touchpad {
       dwt enabled
       tap enabled
       natural_scroll enabled
       middle_emulation enabled
   }

input * {
    xkb_layout "us,ua"
    xkb_options "grp:win_space_toggle"
}

input keyboard xkb_model "pc101"
# You can get the names of your inputs by running: swaymsg -t get_inputs

Special keys

bindsym XF86AudioRaiseVolume exec amixer set Master 5%+
bindsym XF86AudioLowerVolume exec amixer set Master 5%-
bindsym XF86AudioMute exec amixer set Master toggle
bindsym XF86AudioMicMute exec amixer set Capture toggle
bindsym XF86MonBrightnessDown exec brightnessctl set 5%-
bindsym XF86MonBrightnessUp exec brightnessctl set 5%+
bindsym Print exec grim
bindsym XF86AudioPlay exec playerctl play-pause
bindsym XF86AudioNext exec playerctl next
bindsym XF86AudioPrev exec playerctl previous
bindsym XF86Search exec bemenu-run
bindsym Pause exec swaymsg "output eDP-1 dpms toggle"
# get all video outputs: swaymsg -pt get_outputs

Status bar

bar {
    position top
    # When the status_command prints a new line to stdout, swaybar updates.
    # The default just shows the current date and time.
    status_command while date +'%Y-%m-%d %I:%M %p'; do sleep 60; done

    colors {
        statusline #ffffff
        background #32323200
        inactive_workspace #32323200 #32323200 #5c5c5c
    }
}
# Read `man 5 sway-bar` for more information about this section.