############
## VARIABLES
############

# Include per-monitor configuration, not checked in to
# my dotfiles repo
include ./monitors

# UI Font
set $uifont "curie 12px" 

# Modifier key, here we use the Meta/Windows key
set $mod Mod4

# Movement keys
set $left h
set $down j
set $up k
set $right l

# Your preferred terminal editor
set $term kitty

# Your preferred app launcher
set $menu bemenu-run --fn $uifont -i -b -H 20 -p "~>" | xargs swaymsg exec

#############
## APPEARANCE
#############

# Wallpaper
output * bg ~/.config/sway/bg.jpg fill

# Borders
default_border pixel 1
default_floating_border none
smart_borders on

# Font
font Cozette 11

# Focus
# class                 border  backgr. text    indicator child_border
client.focused          #282828 #282828 #ffffff #ffffff   #DDDDDD
client.focused_inactive #282828 #282828 #ffffff #ffffff   #282828
client.unfocused        #282828 #282828 #888888 #ffffff   #282828

# gaps
gaps inner 5
gaps outer 5

# Hide cursor after a while (10 secs)
seat seat0 hide_cursor 10000

##############
## KEYBINDINGS
##############

# Start a terminal
bindsym $mod+Return exec $term

# Start Emacs
bindsym $mod+Shift+Return exec emacs

# Kill focused window
bindsym $mod+Shift+q kill

# Start the program launcher
bindsym $mod+space exec $menu 

# Drag floating windows with the mouse
floating_modifier $mod normal

# Reload the config file
bindsym $mod+Shift+c reload

# Exit sway
bindsym $mod+Shift+e exec swaynag -t warning -m 'Do you want to exit sway?' -b 'Yes' 'swaymsg exit'

# change focus
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+$left move left
bindsym $mod+Shift+$down move down
bindsym $mod+Shift+$up move up
bindsym $mod+Shift+$right move right

# Switch to workspace
bindsym $mod+1 workspace 1
bindsym $mod+2 workspace 2
bindsym $mod+3 workspace 3
bindsym $mod+4 workspace 4

# Move to workspace
bindsym $mod+Shift+1 move container to workspace 1
bindsym $mod+Shift+2 move container to workspace 2
bindsym $mod+Shift+3 move container to workspace 3
bindsym $mod+Shift+4 move container to workspace 4

# Split screen
bindsym $mod+b splith
bindsym $mod+v splitv

# change container layout (stacked, tabbed, toggle split)
bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split

# Fullscreen current container
bindsym $mod+f fullscreen

# Switch between tiling and floating for current container
bindsym $mod+Shift+d floating toggle

# Resize window
bindsym $mod+Alt+h resize shrink width 10
bindsym $mod+Alt+l resize grow width 10
bindsym $mod+Alt+j resize shrink height 10
bindsym $mod+Alt+k resize grow height 10

# Switch between tiling area and floating area
bindsym $mod+d focus mode_toggle

# Screenshots
bindsym $mod+Shift+p exec ~/.config/sway/screen.sh -s
bindsym Shift+Alt+p exec ~/.config/sway/screen.sh

# Volume
bindsym XF86AudioMute exec pamixer -t
bindsym XF86AudioRaiseVolume exec pamixer -i 5
bindsym XF86AudioLowerVolume exec pamixer -d 5
bindsym XF86AudioMicMute exec amixer -D pulse sset Capture toggle

# MPD
bindsym XF86AudioPrev exec mpc prev
bindsym XF86AudioPlay exec mpc toggle
bindsym XF86AudioNext exec mpc next

# Brightness
bindsym XF86MonBrightnessUp exec light -A 10
bindsym XF86MonBrightnessDown exec light -U 10

# Lock
bindsym XF86Sleep exec swaylock -f -C ~/.config/swaylock/config

#######
## Idle
#######

exec swayidle -w timeout 1800 'swaylock -f -C ~/.config/swaylock/config' \
          timeout 2000 'swaymsg "output * dmps off"' \
          resume 'swaymsg "output * dpms on"' \
          before-sleep 'swaylock -f -C ~/.config/swaylock/config'

# Touchpad tap-to-click
input type:touchpad {
  tap enabled
  click_method clickfinger
  dwt enabled
}

################
## Exec on start
################

# Notifications
exec mako

# Bar
exec waybar