### Catppuccin latte color palette
set $rosewater #dc8a78
set $flamingo  #dd7878
set $pink      #ea76cb
set $mauve     #8839ef
set $red       #d20f39
set $maroon    #e64553
set $peach     #fe640b
set $yellow    #df8e1d
set $green     #40a02b
set $teal      #179299
set $sky       #04a5e5
set $sapphire  #209fb5
set $blue      #1e66f5
set $lavender  #7287fd
set $text      #4c4f69
set $subtext1  #5c5f77
set $subtext0  #6c6f85
set $overlay2  #7c7f93
set $overlay1  #8c8fa1
set $overlay0  #9ca0b0
set $surface2  #acb0be
set $surface1  #bcc0cc
set $surface0  #ccd0da
set $base      #eff1f5
set $mantle    #e6e9ef
set $crust     #dce0e8

### Font
font "Mononoki Nerd Font" 12

### Window borders
default_border none

### Wallpaper
output * bg @DOTFILES_DIR@/images/sam_yang_0.jpg fill

### Variables

# Mod key is Super key
set $mod Mod4

# Movement
set $left b
set $down n
set $up p
set $right f

# Terminal
set $term foot

# Menus
set $bemenu bemenu --fn "Mononoki Nerd Font 14" --fb "#eff1f5" --ff "#4c4f69" --nb "#eff1f5" --nf "#4c4f69" --tb "#eff1f5" --hb "#eff1f5" --tf "#d20f39" --hf "#df8e1d" --af "#4c4f69" --ab "#eff1f5" --hp 10
set $program-menu cat @DOTFILES_DIR@/bemenu/programs.txt | $bemenu -p "Program:" | xargs swaymsg exec --
set $power-menu cat @DOTFILES_DIR@/bemenu/power.txt | $bemenu -p "Action:" | xargs systemctl

### Idle
exec swayidle -w \
         timeout 300 "sudo systemctl sleep"\
         before-sleep "swaylock -f -i @DOTFILES_DIR@/images/sam_yang_0.jpg"

### Input
input "type:keyboard" {
    xkb_layout fr
    xkb_options caps:ctrl_modifier
    repeat_delay 200
    repeat_rate 60
}

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

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

# Start a program
bindsym $mod+a exec $program-menu

# Power management
bindsym $mod+e exec $power-menu

# Moving and resizing windows
floating_modifier $mod normal

# Reload config
bindsym $mod+Shift+r reload

# Exit Sway
bindsym $mod+Shift+q exec swaymsg exit

# Fullscreen
bindsym f11 fullscreen

# Swap focus between tiling and floating
bindsym $mod+space focus mode_toggle

# Screenshot
bindsym $mod+c exec @DOTFILES_DIR@/scripts/screenshot.sh

### Floating
bindsym $mod+Shift+space floating toggle
for_window [class="Pinentry-gtk"] floating enable

### Moving
# Move 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

### Workspaces
# Names
set $workspace1 1
set $workspace2 2
set $workspace3 3
set $workspace4 4
set $workspace5 5
set $workspace6 6
set $workspace7 7
set $workspace8 8
set $workspace9 9
set $workspace0 0

# Switch
bindsym $mod+ampersand  workspace $workspace1
bindsym $mod+eacute     workspace $workspace2
bindsym $mod+quotedbl   workspace $workspace3
bindsym $mod+apostrophe workspace $workspace4
bindsym $mod+parenleft  workspace $workspace5
bindsym $mod+minus      workspace $workspace6
bindsym $mod+egrave     workspace $workspace7
bindsym $mod+underscore workspace $workspace8
bindsym $mod+ccedilla   workspace $workspace9
bindsym $mod+agrave     workspace $workspace0

# Send windows
bindsym $mod+Shift+ampersand  move container to workspace $workspace1
bindsym $mod+Shift+eacute     move container to workspace $workspace2
bindsym $mod+Shift+quotedbl   move container to workspace $workspace3
bindsym $mod+Shift+apostrophe move container to workspace $workspace4
bindsym $mod+Shift+parenleft  move container to workspace $workspace5
bindsym $mod+Shift+minus      move container to workspace $workspace6
bindsym $mod+Shift+egrave     move container to workspace $workspace7
bindsym $mod+Shift+underscore move container to workspace $workspace8
bindsym $mod+Shift+ccedilla   move container to workspace $workspace9
bindsym $mod+Shift+agrave     move container to workspace $workspace0

### Resizing containers:
mode "resize" {
    bindsym $left  resize shrink width  10px
    bindsym $down  resize grow   height 10px
    bindsym $up    resize shrink height 10px
    bindsym $right resize grow   width  10px

    # Exit
    bindsym Return mode "default"
    bindsym Escape mode "default"
    bindsym $mod+g mode "default"
}
bindsym $mod+r mode "resize"

### Brightness
mode "brightness" {
    bindsym $up   exec brillo -q -A 5
    bindsym $down exec brillo -q -U 5

    # Exit
    bindsym Return mode "default"
    bindsym Escape mode "default"
    bindsym $mod+g mode "default"
    bindsym $mod+b mode "default"
    bindsym b mode "default"
}
bindsym $mod+l mode "brightness"

### Sound
bindsym --locked XF86AudioMute        exec wpctl set-mute          @DEFAULT_AUDIO_SINK@ toggle
bindsym --locked XF86AudioLowerVolume exec wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 5%-
bindsym --locked XF86AudioRaiseVolume exec wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 5%+
bindsym --locked Shift+XF86AudioLowerVolume exec wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 1%-
bindsym --locked Shift+XF86AudioRaiseVolume exec wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 1%+
mode "sound" {
    bindsym $up   exec wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 5%+
    bindsym $down exec wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 5%-
    bindsym m     exec wpctl set-mute          @DEFAULT_AUDIO_SINK@ toggle

    # Exit
    bindsym Return mode "default"
    bindsym Escape mode "default"
    bindsym $mod+g mode "default"
    bindsym $mod+s mode "default"
    bindsym s mode "default"
}
bindsym $mod+s mode "sound"


### Bar
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

bar {
    position top
    separator_symbol |

    status_command "$DOTFILES_DIR/config/sway/bar.sh"

    colors {
        background         $base
        statusline         $text
        focused_statusline $text
        active_workspace   $base $text $blue
        focused_separator  $base
        focused_workspace  $base $base $green
        active_workspace   $base $base $blue
        inactive_workspace $base $base $surface1
        urgent_workspace   $base $base $surface1
        binding_mode       $base $base $surface1
    }
}

### Important system-wide config
include /etc/sway/config.d/*

### Machine-Specific Config
include @HOSTNAME@

# Local Variables:
# mode: conf-unix
# eval: (rainbow-mode 1)
# End:
