Skip to content

Instantly share code, notes, and snippets.

@kkoyung
Created February 13, 2025 07:15
Show Gist options
  • Save kkoyung/d7201bffbeb60ce0acfe48dcb6d63e28 to your computer and use it in GitHub Desktop.
Save kkoyung/d7201bffbeb60ce0acfe48dcb6d63e28 to your computer and use it in GitHub Desktop.
Sway configuration
# Config for sway
#
# Read `man 5 sway` for a complete reference.
######################################################################
### Variables
#
# Logo key. Use Mod1 for Alt.
set $mod Mod4
# Home row direction keys, like vim
set $left h
set $down j
set $up k
set $right l
# Your preferred terminal emulator
set $term kitty
# set $term foot
# Your preferred application launcher
set $menu rofi -modes 'run,search:rofi-search,window' -show run
# Monitor id
set $primary HDMI-A-1
set $secondary DVI-D-1
######################################################################
### Output configuration
#
# Default wallpaper (more resolutions are available in /usr/share/backgrounds/sway/)
#
# output * bg /usr/share/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill
#
# Example configuration:
#
# output HDMI-A-1 resolution 1920x1080 position 1920,0
#
# You can get the names of your outputs by running: swaymsg -t get_outputs
output $primary resolution 1920x1080 position 0,0 bg ~/Pictures/wallpaper/left.jpg fill
output $secondary resolution 1920x1080 position 1920,0 bg ~/Pictures/wallpaper/right.jpg fill
focus output $primary
######################################################################
### Idle configuration
#
# Example configuration:
#
# exec swayidle -w \
# timeout 300 'swaylock -f -c 000000' \
# timeout 600 'swaymsg "output * power off"' resume 'swaymsg "output * power on"' \
# before-sleep 'swaylock -f -c 000000'
#
# This will lock your screen after 300 seconds of inactivity, then turn off
# your displays after another 300 seconds, and turn your screens back on when
# resumed. It will also lock your screen before your computer goes to sleep.
# exec swayidle -w \
# timeout 600 'swaylock -f -i ~/Pictures/wallpaper/lock.jpg' \
# timeout 900 'swaymsg "output * power off"' resume 'swaymsg "output * power on"' \
# before-sleep 'swaylock -f -i ~/Pictures/wallpaper/lock.jpg'
exec swayidle -w \
timeout 900 'swaymsg "output * power off"' resume 'swaymsg "output * power on"'
# timeout 900 'swaymsg "output * power off"' resume 'swaymsg "output * power on"' \
# timeout 930 'swaylock -f -i ~/Pictures/wallpaper/lock.jpg' \
# before-sleep 'swaylock -f -i ~/Pictures/wallpaper/lock.jpg'
######################################################################
### Input configuration
#
# Example configuration:
#
# input "2:14:SynPS/2_Synaptics_TouchPad" {
# dwt enabled
# tap enabled
# natural_scroll enabled
# middle_emulation enabled
# }
#
# You can get the names of your inputs by running: swaymsg -t get_inputs
# Read `man 5 sway-input` for more information about this section.
# Set numpad always returning digits
input type:keyboard xkb_options numpad:mac
######################################################################
### Key bindings
#
# Basics:
#
# Start a terminal
bindsym $mod+Return exec $term
# Kill focused window
bindsym $mod+Shift+q kill
# Start your launcher
bindsym $mod+a exec $menu
bindsym $mod+space exec $menu
# Drag floating windows by holding down $mod and left mouse button.
# Resize them with right mouse button + $mod.
# Despite the name, also works for non-floating windows.
# Change normal to inverse to use left mouse button for resizing and right
# mouse button for dragging.
floating_modifier $mod normal
# Reload the configuration file
bindsym $mod+Shift+c reload
# 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'
# Disable focus_follows_mouse
focus_follows_mouse no
#
# Moving around:
#
# Move your focus around
bindsym $mod+$left focus left
bindsym $mod+$down focus down
bindsym $mod+$up focus up
bindsym $mod+$right focus right
# Or use $mod+[up|down|left|right]
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right
# Move the focused window with the same, but add Shift
bindsym $mod+Shift+$left move left
bindsym $mod+Shift+$down move down
bindsym $mod+Shift+$up move up
bindsym $mod+Shift+$right move right
# Ditto, with arrow 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
#
# Workspaces:
#
# Define workspace name
set $ws0 "0"
set $ws1 "1"
set $ws2 "2"
set $ws3 "3"
set $ws4 "4"
set $ws5 "5"
set $ws6 "6"
set $ws7 "7"
set $ws8 "8"
set $ws9 "9"
set $ws10 "10"
set $wszen "zen"
# Switch to workspace
bindsym $mod+grave workspace $ws0
bindsym $mod+1 workspace $ws1
bindsym $mod+2 workspace $ws2
bindsym $mod+3 workspace $ws3
bindsym $mod+4 workspace $ws4
bindsym $mod+5 workspace $ws5
bindsym $mod+6 workspace $ws6
bindsym $mod+7 workspace $ws7
bindsym $mod+8 workspace $ws8
bindsym $mod+9 workspace $ws9
bindsym $mod+0 workspace $ws10
bindsym $mod+z workspace $wszen
# Move focused container to workspace
bindsym $mod+Shift+grave move container to workspace $ws0
bindsym $mod+Shift+1 move container to workspace $ws1
bindsym $mod+Shift+2 move container to workspace $ws2
bindsym $mod+Shift+3 move container to workspace $ws3
bindsym $mod+Shift+4 move container to workspace $ws4
bindsym $mod+Shift+5 move container to workspace $ws5
bindsym $mod+Shift+6 move container to workspace $ws6
bindsym $mod+Shift+7 move container to workspace $ws7
bindsym $mod+Shift+8 move container to workspace $ws8
bindsym $mod+Shift+9 move container to workspace $ws9
bindsym $mod+Shift+0 move container to workspace $ws10
bindsym $mod+Shift+z move container to workspace $wszen
# Note: workspaces can have any name you want, not just numbers.
# We just use 1-10 as the default.
# Monitor default workspace
workspace $ws1 output $primary
workspace $ws0 output $primary
workspace $ws10 output $secondary
# Move workspace to another output
bindsym $mod+Shift+comma move workspace to output left
bindsym $mod+Shift+period move workspace to output right
# Cycle workspaces
bindsym $mod+o workspace next_on_output
bindsym $mod+i workspace prev_on_output
#
# Layout stuff:
#
# You can "split" the current object of your focus with
# $mod+b or $mod+v, for horizontal and vertical splits
# respectively.
bindsym $mod+b splith
bindsym $mod+v splitv
# Switch the current container between different layout styles
bindsym $mod+Alt+s layout stacking
bindsym $mod+Alt+w layout tabbed
bindsym $mod+Alt+e layout toggle split
# Make the current focus fullscreen
bindsym $mod+f fullscreen
# Toggle the current focus between tiling and floating mode
bindsym $mod+Shift+space floating toggle
# Swap focus between the tiling area and the floating area
bindsym $mod+Alt+space focus mode_toggle
# Move focus to the parent container
bindsym $mod+Alt+a focus parent
#
# Scratchpad:
#
# Sway has a "scratchpad", which is a bag of holding for windows.
# You can send windows there and get them back later.
# Move the currently focused window to the scratchpad
bindsym $mod+Shift+minus move scratchpad
# Show the next scratchpad window or hide the focused scratchpad window.
# If there are multiple scratchpad windows, this command cycles through them.
bindsym $mod+minus scratchpad show
#
# Resizing containers:
#
mode "resize" {
# left will shrink the containers width
# right will grow the containers width
# up will shrink the containers height
# down will grow the containers height
bindsym $left resize shrink width 10px
bindsym $down resize grow height 10px
bindsym $up resize shrink height 10px
bindsym $right resize grow width 10px
# Ditto, with arrow keys
bindsym Left resize shrink width 10px
bindsym Down resize grow height 10px
bindsym Up resize shrink height 10px
bindsym Right resize grow width 10px
# Return to default mode
bindsym Return mode "default"
bindsym Escape mode "default"
}
bindsym $mod+r mode "resize"
#
# Hotkey:
#
# Audio
bindsym XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +5%
bindsym XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -5%
bindsym XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle
bindsym XF86AudioMicMute exec pactl set-source-mute @DEFAULT_SOURCE@ toggle
# Calculator
bindsym XF86Calculator exec qalculate-gtk
# Screenshot
# primary screen
bindsym Print exec grim -g "0,0 1920x1080" ~/Desktop/screenshot_`date +%Y-%m-%d_%H:%M:%S`.png
# primary screen + annotation
bindsym Shift+Print exec grim -g "0,0 1920x1080" - | swappy -f - -o ~/Desktop/screenshot_`date +%Y-%m-%d_%H:%M:%S`.png
# select area
bindsym $mod+Print exec grim -g "$(slurp -w 4)" ~/Desktop/screenshot_`date +%Y-%m-%d_%H:%M:%S`.png
# select area + annotation
bindsym $mod+Shift+Print exec grim -g "$(slurp -w 4)" - | swappy -f - -o ~/Desktop/screenshot_`date +%Y-%m-%d_%H:%M:%S`.png
# Gammastep
bindsym Pause exec pkill gammastep || gammastep
# Search via rofi
bindsym $mod+q exec rofi -modes 'search:rofi-search' -show search
# Switch window via rofi
bindsym $mod+Tab exec rofi -modes 'window' -show window
# Focus mode
bindsym $mod+Shift+bracketleft gaps horizontal current set 571
bindsym $mod+Shift+bracketright gaps horizontal current set 0
# Output toggle
bindsym $mod+Shift+n output $primary toggle
bindsym $mod+Shift+m output $secondary toggle
######################################################################
### Border
default_border pixel 2
default_floating_border pixel 2
# Use catppuccin-macchiato theme from https://github.com/catppuccin/i3
include catppuccin-macchiato
# target title bg text indicator border
client.focused $lavender $base $text $rosewater $lavender
client.focused_inactive $overlay0 $base $text $rosewater $overlay0
client.unfocused $overlay0 $base $text $rosewater $overlay0
client.urgent $peach $base $peach $overlay0 $peach
client.placeholder $overlay0 $base $text $overlay0 $overlay0
client.background $base
######################################################################
### Window rules
#
# Opacity:
#
set $opacity 0.95
for_window [app_id="kitty"] opacity 1
for_window [app_id="foot"] opacity $opacity
for_window [app_id="com.chatterino.chatterino" title="Chatterino(?! - Overlay)"] opacity $opacity
for_window [app_id="org.telegram.desktop"] opacity $opacity
for_window [class="Signal"] opacity $opacity
for_window [class="Element"] opacity $opacity
#
# Floating:
#
for_window [app_id="com.chatterino.chatterino" title="Chatterino - Overlay"] floating enable, border none, resize set 400 500, move position 1520 0
for_window [app_id="org.keepassxc.KeePassXC"] floating enable
for_window [app_id="qalculate-gtk"] floating enable
for_window [app_id="matplotlib"] floating enable
for_window [app_id="io.crow_translate.CrowTranslate"] floating enable
for_window [app_id="anki"] floating enable
for_window [app_id="thunderbird" title="Write:*"] floating enable
for_window [app_id="syncthingtray"] floating enable
for_window [title="^Syncthing Tray( \(.*\))?$"] floating enable, border none, resize set 450 400, move position 1470 0
for_window [class="Todoist"] floating enable, move scratchpad
for_window [class="superProductivity"] floating enable
######################################################################
### Status Bar
#
# Read `man 5 sway-bar` for more information about this section.
# 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:%S %p'; do sleep 1; done
#
# colors {
# statusline #ffffff
# background #323232
# inactive_workspace #32323200 #32323200 #5c5c5c
# }
# }
bar {
swaybar_command waybar
}
######################################################################
### Autostart
# exec_always "pkill waybar; waybar"
exec fcitx5 -d
exec systemctl --user start sway-audio-idle-inhibit
exec sleep 10 && syncthingtray
######################################################################
include /etc/sway/config.d/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment