set $nord0  #2E3440
set $nord1  #3B4252
set $nord2  #434C5E
set $nord3  #4C566A
set $nord4  #D8DEE9
set $nord5  #E5E9F0
set $nord6  #ECEFF4
set $nord7  #8FBCBB
set $nord8  #88C0D0
set $nord9  #81A1C1
set $nord10 #5E81AC
set $nord11 #BF616A
set $nord12 #D08770
set $nord13 #EBCB8B
set $nord14 #A3BE8C
set $nord15 #B48EAD
set $bg $nord3
set $fg $nord5


set $mod Mod4
set $left c
set $down t
set $up s
set $right r
set $term kitty
set $menu "rofi -combi-modi drun -show combi"

output eDP-1 {
  mode 1920x1080@120Hz
  position 2560,0
  bg /home/phundrak/Pictures/Wallpapers/nord/spacemars.jpg fill
}

output HDMI-A-1 {
  mode 2560x1080@60Hz
  position 0,0
  bg /home/phundrak/Pictures/Wallpapers/nord/spacemars.jpg fill
}

exec swayidle -w \
         timeout 600 'swaymsg "output * power off"' resume 'swaymsg "output * power on"' \
         timeout 601 'plock' \
         before-sleep 'playerctl pause' \
         before-sleep 'plock'

input "2:14:ETPS/2_Elantech_Touchpad" {
  dwt enabled
  tap enabled
  natural_scroll disabled
  middle_emulation enabled
}

input "1267:12642:ELAN0412:00_04F3:3162_Touchpad" {
  dwt enabled
  tap enabled
  natural_scroll disabled
  middle_emulation enabled
}

input "1386:792:Wacom_USB_Bamboo_PAD_Finger" {
  dwt enabled
  tap enabled
  middle_emulation enabled
}

input "1386:792:Wacom_USB_Bamboo_PAD_Pen" {
  map_to_output HDMI-A-1
}

input * {
    xkb_layout "fr"
    xkb_variant "bepo_afnor"
    xkb_options "caps:ctrl_modifier"
}

input type:keyboard xkb_numlock enabled


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

  bindsym Return mode "default"
  bindsym Escape mode "default"
  bindsym Ctrl+g mode "default"
  bindsym q      mode "default"
}

mode "buffers" {
  bindsym d kill; mode "default"

  bindsym Return mode "default"
  bindsym Escape mode "default"
  bindsym Ctrl+g mode "default"
  bindsym q      mode "default"
}

mode "rofi" {
  bindsym a       exec awiki;             mode "default"
  bindsym b       exec bluetooth-connect; mode "default"
  bindsym e       exec rofi-emoji;        mode "default"
  bindsym r       exec $menu;             mode "default"
  bindsym s       exec rofi -show ssh;    mode "default"
  bindsym y       exec ytplay;            mode "default"
  bindsym Shift+y exec rofi-ytdl;         mode "default"

  bindsym Return mode "default"
  bindsym Escape mode "default"
  bindsym Ctrl+g mode "default"
  bindsym q      mode "default"
}

mode "apps" {
  bindsym b       exec firefox;        mode "default"
  bindsym Shift+b exec qutebrowser;    mode "default"
  bindsym d       exec discord;        mode "default"
  bindsym e       exec emacsclient -c; mode "default"
  bindsym g       exec gimp;           mode "default"
  bindsym n       exec nemo;           mode "default"
  bindsym r       mode "rofi"

  bindsym Return mode "default"
  bindsym Escape mode "default"
  bindsym Ctrl+g mode "default"
  bindsym q      mode "default"
}

mode "windows" {
  bindsym period       mode "resize"

  bindsym $left        focus left;                     mode "default"
  bindsym $right       focus right;                    mode "default"
  bindsym $up          focus up;                       mode "default"
  bindsym $down        focus down;                     mode "default"
  bindsym Shift+$left  move left;                      mode "default"
  bindsym Shift+$right move right;                     mode "default"
  bindsym Shift+$up    move up;                        mode "default"
  bindsym Shift+$down  move down;                      mode "default"
  bindsym Ctrl+$left   move workspace to output left;  mode "default"
  bindsym Ctrl+$right  move workspace to output right; mode "default"
  bindsym Ctrl+$up     move workspace to output up;    mode "default"
  bindsym Ctrl+$down   move workspace to output down;  mode "default"

  bindsym slash splith; mode "default"
  bindsym minus splitv; mode "default"

  bindsym a       focus parent;      mode "default"
  bindsym d       kill;              mode "default"
  bindsym f       fullscreen;        mode "default"
  bindsym Shift+f floating toggle;   mode "default"
  bindsym Space   focus mode_toggle; mode "default"

  bindsym e       layout toggle split; mode "default"
  bindsym i       layout tabbed;       mode "default"
  bindsym u       layout stacking;     mode "default"

  bindsym Return mode "default"
  bindsym Escape mode "default"
  bindsym Ctrl+g mode "default"
  bindsym q      mode "default"
}

mode "sway" {
  bindsym r reload
  bindsym q 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'

  bindsym Return mode "default"
  bindsym Escape mode "default"
  bindsym Ctrl+g mode "default"
}

mode "leader" {
  bindsym minus move scratchpad; mode "default"
  bindsym plus  scratchpad show; mode "default"

  bindsym a     mode "apps"
  bindsym b     mode "buffers"
  bindsym l     exec "plock"; mode "default"
  bindsym q     mode "sway"
  bindsym w     mode "windows"

  bindsym Return mode "default"
  bindsym Escape mode "default"
  bindsym Ctrl+g mode "default"
}

bindsym     $mod+$left        focus left
bindsym     $mod+$right       focus right
bindsym     $mod+$up          focus up
bindsym     $mod+$down        focus down
bindgesture swipe:3:left      focus left
bindgesture swipe:3:right     focus right
bindgesture swipe:3:up        focus up
bindgesture swipe:3:down      focus down
bindsym     Shift+$mod+$left  move left
bindsym     Shift+$mod+$right move right
bindsym     Shift+$mod+$up    move up
bindsym     Shift+$mod+$down  move down
bindgesture swipe:4:left      move left
bindgesture swipe:4:right     move right
bindgesture swipe:4:up        move up
bindgesture swipe:4:down      move down

mode "screenshot" {
  bindsym Print   exec "screenshot";      mode "default"
  bindsym c       exec "screenshot -c";   mode "default"
  bindsym s       exec "screenshot -s";   mode "default"
  bindsym g       exec "screenshot -g";   mode "default"
  bindsym d       exec "screenshot -d 3"; mode "default"
  bindsym Shift+s exec "screenshot -sc";  mode "default"

  bindsym Return mode "default"
  bindsym Escape mode "default"
  bindsym Ctrl+g mode "default"
  bindsym q      mode "default"
}

bindsym $mod+Space  mode "leader"
bindsym $mod+Return exec $term
bindsym $mod+d      exec $menu
bindsym Print       mode "screenshot"
bindsym $mod+Print  exec "screenshot -c"

bindsym $mod+quotedbl       workspace number 1
bindsym $mod+guillemotleft  workspace number 2
bindsym $mod+guillemotright workspace number 3
bindsym $mod+parenleft      workspace number 4
bindsym $mod+parenright     workspace number 5
bindsym $mod+at             workspace number 6
bindsym $mod+plus           workspace number 7
bindsym $mod+minus          workspace number 8
bindsym $mod+slash          workspace number 9
bindsym $mod+asterisk       workspace number 0

bindsym $mod+Shift+quotedbl       move container to workspace number 1
bindsym $mod+Shift+guillemotleft  move container to workspace number 2
bindsym $mod+Shift+guillemotright move container to workspace number 3
bindsym $mod+Shift+parenleft      move container to workspace number 4
bindsym $mod+Shift+parenright     move container to workspace number 5
bindsym $mod+Shift+at             move container to workspace number 6
bindsym $mod+Shift+plus           move container to workspace number 7
bindsym $mod+Shift+minus          move container to workspace number 8
bindsym $mod+Shift+slash          move container to workspace number 9
bindsym $mod+Shift+asterisk       move container to workspace number 0

bindsym --locked XF86AudioPlay         exec playerctl play-pause
bindsym --locked XF86AudioPause        exec playerctl pause
bindsym --locked XF86AudioStop         exec playerctl stop
bindsym --locked XF86AudioPrev         exec playerctl previous
bindsym --locked XF86AudioNext         exec playerctl next
bindsym --locked XF86AudioForward      exec playerctl position +1
bindsym --locked XF86AudioRewind       exec playerctl position -1
bindsym --locked XF86AudioRaiseVolume  exec pamixer -i 2
bindsym --locked XF86AudioLowerVolume  exec pamixer -d 2
bindsym XF86MonBrightnessUp            exec xbacklight -perceived -inc 2
bindsym XF86MonBrightnessDown          exec xbacklight -perceived -dec 2
bindsym XF86KbdBrightnessUp            exec xbacklight -perceived -inc 2
bindsym XF86KbdBrightnessDown          exec xbacklight -perceived -dec 2

floating_modifier $mod normal

gaps outer 15px
gaps inner 20px
default_border pixel 2
smart_borders on

# class                 border  background text   indicator child_border
client.urgent           $nord11 $nord11    $nord6 $nord11   $nord1
client.focused          $nord3  $nord3     $nord5 $nord3    $nord3
client.focused_inactive $nord2  $nord2     $nord5 $nord2    $nord2
client.unfocused        $nord0  $nord0     $nord4 $nord0    $nord0
client.placeholder      $nord7  $nord7     $nord6 $nord7    nord7

#
# 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.
    height 20
    status_command while swaybar-cmd; do sleep 1; done
    font FantasqueSansMono Nerd Font Mono 10

    colors {
        statusline $nord5
        background $nord3

        #                  border  bg      text
        focused_workspace  $nord10 $nord10 $nord5
        active_workspace   $nord9  $nord9  $nord5
        inactive_workspace $nord7  $nord7  $nord5
        urgent_workspace   $nord11 $nord11 $nord6
        binding_mode       $nord14 $nord14 $nord6
    }
}

include /etc/sway/config.d/*
