Files
2025-12-19 22:14:51 -07:00

3.5 KiB

title, date, tags, draft
title date tags draft
Sway Config 2021-05-06T19:23:15-06:00
sway
config
false

I had been using dwm for a very long time. The keyboard focused interface and minimal resource usage were very appealing to me. When swaywm reached 1.0 release I gave it a try and was hooked. The only thing I really miss from dwm is the default window layout. Wayland uses less resources than xwindows for some reason and all the configuration is in the sway config or the configs for any apps, there is no Xresources and whatever other crazy amount of configs there were for xwindows and it's stack.

Progams that I'm using:

  • swaywm: compositor and window manager
  • waybar: bar and tray
  • mako: notification daemon, replaces twmn from dwm setup
  • alacritty: terminal, switched from termite since it is no longer maintained.
  • wofi: launcher, replaces dmenu from dwm setup

Sway allows for the config to be split between files using include path/to/file/. The include directive with parse out things like $(hostname) so that a machine specific config can be used as well as a default. I used this to create a seperate display config for my home workstation/laptop and my traveling laptop. One has 3 screens and the other typically only one hiDPI screen. This also works well with my new dotfiles approach. Onto the configuration goodies. Set some variables to use in the config

### Variables
#
# Logo key. Use Mod1 for Alt.
set $mod Mod1
# Home row direction keys, like vim
set $left h
set $down j
set $up k
set $right l
# Your preferred terminal emulator
set $term alacritty
# Your preferred application launcher
set $menu wofi
# setup grim and slurp for screen shots
set $screenshot grim ~/Images/screenshots/scrn-$(date +"%Y%m%d-%H%M%S").png
set $screenclip slurp | grim -g - ~/Images/screenshots/scrn-$(date +"%Y%m%d-%H%M%S").png
set $mail termite --name=mail
set $mixer termite --name=mixer
set $volume /home/ewpt3ch/bin/volumeset

Setup the input devices:

### Input configuration
# set capslock to be control
    input * xkb_options ctrl:nocaps
# need to move this to machine level config
    input "2:7:SynPS/2_Synaptics_TouchPad" {
        accel_profile adaptive
        pointer_accel .5
        dwt enabled
        tap enabled
        tap_button_map lrm
    }

Hide the cursor after time or when typing:

# hide mouse cursor¬
seat seat0 hide_cursor 5000¬
seat seat0 hide_cursor when-typing enable

Some keybindings showing the use of previously set variables

### Key bindings
#
# Notifications
bindsym Control+Space exec makoctl dismiss
bindsym Control+Shift+Space exec makoctl dismiss --all

# Screen capture
bindsym $mod+Print exec $screenshot
bindsym $mod+Shift+Print exec $screenclip

#media
bindsym XF86AudioMute exec $volume mute
bindsym XF86AudioRaiseVolume exec $volume up
bindsym XF86AudioLowerVolume exec $volume down

I got this python script to make inactive windows transparent, we start it like

exec --no-startup-id python ~/bin/inactive-windows-transparency.py

Then the very last lines of the config bring in a system-wide default that gets updated by pacman and my machine-specific configurations

include /etc/sway/config.d/*
include ~/.config/sway/$(hostname)/*