Arch :: Sway

Sway

System Setup

Config

# parse output of get_tree
# X11 window will have `window_properties.class`
# wayland use `app_id`
swaymsg -t get_tree | grep window_properties

# `xprop` from `xorg-xprop` package
# X11 window will have crosshair

# use %shell var in sway config
# wayland native %shell is xdg_shell
# xwayland is xwayland
for_window [shell="xwayland"] title_format "%shell: %title"
# example /etc/sway/config
~/.config/sway/config

# some .desktop files require a default term, and will use xterm
sudo ln -s /usr/bin/foot /usr/local/bin/xterm

# exec essentially pass to /bin/sh -c
# multiple commands use ; or &&
exec command_1; command_2

# no title bar
default_border pixel 2

# wofi
set $menu wofi --show drun --no-actions --insensitive --prompt 'Open' | xargs swaymsg exec --

# use fzf for launcher
set $menu exec $term --app-id fzf-menu sh -c "ls /usr/share/applications/ | sort -u | fzf --height=100% --preview-window hidden | xargs -r swaymsg -t command exec gtk-launch"
for_window [app_id="^fzf-menu$"] floating enable, resize set 600 800, border none, opacity 0.8, move position center
for_window [app_id="firefox" title="About Mozilla Firefox"] floating enable

## use fzf for selection
case $(fzf << EOF
Opt1
Opt2
Opt3
EOF
) in
"Opt1")
    command ;;
"Opt2")
    command2 ;;
"Opt3")
    command3 ;;
esac

# disable an ouput
output eDP-1 disable # disable laptop screen when lid is closed

# change monitor refresh rate
output HDMI-A-1 resolution 2560x1080@60Hz bg #000000 solid_color

# change touchpad
input type:touchpad {
  natural_scroll enabled
}

# remap keys
# keyd can be used too
input type:keyboard {
    xkb_options ctrl:nocaps
}

# adjust bluelight filter
exec gammastep -PO 3500
exec wlsunset -t 3500 -T 3501

# clip board
# clipman (AUR)
exec wl-paste --type text --watch clipman store

# screenshots
set $screenshot grim ~/Downloads/scrn-$(date +"%Y-%m-%d-%H-%M-%S").png
set $screenclip slurp | grim -g - ~/Downloads/scrn-$(date +"%Y-%m-%d-%H-%M-%S").png
bindsym $mod+Print exec $screenshot
bindsym $mod+Shift+Print exec $screenclip

# autotiling-rs

Qutebrowser

Themes


# cursor
seat seat0 {
    hide_cursor 5000
    xcursor_theme capitaine-cursors 30
}
# https://github.com/swayvm/sway/wiki/GTK-3-settings-on-Wayland
exec_always {
    gsettings set org.gnome.desktop.interface cursor-theme capitaine-cursors
    gsettings set org.gnome.desktop.interface cursor-size 30
    gsettings set org.gnome.desktop.interface gtk-theme 'Arc-Darker'
    gsettings set org.gnome.desktop.interface icon-theme la-capitaine
    gsettings set org.gnome.desktop.interface font-name 'sans-serif 10'
}

Fingerprint auth

# need an authentication agents
pacman -S polkit-gnome
# in sway setting
exec /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1

# add user to input group
gpasswd -a $USER input

# enroll fingerprint
fprintd-enroll
fprintd-verify $USER

# swaylock setting; remove `ignore-empty-password`
# /etc/pam.d/swaylock
auth sufficient	pam_unix.so try_first_pass likeauth nullok
auth sufficient	pam_fprintd.so

Utilities

# audio
pipewire, and pipewire-pulse

# network
nmtui   # networkmanager package

# bluetooth
# need to enable bluetooth.service
# and /etc/bluetooth/main.conf to AutoEnable=true
bluetoothctl    # bluez, bluez-utils

# night light
## redshift not working in Wayland
gammastep
~/.config/gammastep/config.ini
    [general]
    temp-day=3500
    temp-night=3500

    location-provider=manual

    [manual]
    lat=48.1
    lon=11.6

# wlsunset works too
wlsunset -t 3500 -T 4500

# notification
# need `libnotify` if it's not installed
#mako    # no need to `exec mako` in config
dunst    # use dunst for better icon and progress bar support

# auto mount
udisks2
udiskie
exec udiskie --smart-tray

# pdf
zathura-pdf-mupdf

# image viewer
imv
# bind tablet mode
bindswitch --reload --locked tablet:on exec 'something'

## on screen keyboard
wvkbd

## touchpad gesture
lisgd
libinput-gestures
# add to input group
gpasswd -a $USER input
newgrp input
# autostart libinput-gestures doesnt work for desktop
# add to sway config file
exec /usr/bin/libinput-gestures-setup start

## screen rotation
rot8

Start with systemd

# ~/.local/share/systemd/user/sway.service
[Unit]
Description=Sway
Documentation=man:sway(5)

[Service]
Type=simple
Environment="WLR_BACKENDS=headless" "WLR_LIBINPUT_NO_DEVICES=1"
ExecStart=/usr/bin/sway
Restart=always

[Install]
WantedBy=default.target

Waybar

# default status bar is swaybar
## alternative
bar {
    swaybar_command waybar
}

# config
~/.config/waybar/config
~/.config/waybar/style.css

WayVNC

# install
pacman -S wayvnc

# config
~/.config/wayvnc/config
    address=localhost
    port=5900
    enable_auth=false

# run in headless mode
export WLR_BACKENDS=headless
export WLR_LIBINPUT_NO_DEVICES=1
export WAYLAND_DISPLAY=wayland-1
$ WLR_BACKENDS=headless WLR_LIBINPUT_NO_DEVICES=1 sway
$ WAYLAND_DISPLAY=wayland-1 wayvnc

# start wayvnc automatically with sway
# add to the end of sway config file
# exec_always would run even reloading config files
exec wayvnc

# screen is HEADLESS
output HEADLESS-1 resolution 1600x900 scale 1

# change screen resolution on the fly
swaymsg output HEADLESS_1 res 1600x900

Passthrough mode

mode passthrough {
    bindsym $mod+Pause mode default
}
bindsym $mod+Pause mode passthrough