include ./monitors
include ./exec
include ./theme

exec dbus-update-activation-environment --systemd \
    WAYLAND_DISPLAY \
    XDG_CURRENT_DESKTOP=sway \
    QT_QPA_PLATFORMTHEME=qt6ct
set $gnome-schema org.gnome.desktop.interface
exec_always {
    export WLR_NO_HARDWARE_CURSORS=1
    export GBM_BACKEND=nvidia-drm
    export __GLX_VENDOR_LIBRARY_NAME=nvidia
    export WLR_RENDERER=vulkan
}

include "$(/usr/libexec/sway/layered-include '/usr/share/sway/config.d/*.conf' '/etc/sway/config.d/*.conf')"

set $mod Mod4

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

set $term kitty
set $menu kitty --app-id fsel fsel -r -d
set $launcher kitty --app-id otter-launcher otter-launcher
set $browser /home/henry/AppImages/helium.appimage
set $filemanager kitty -e yazi
focus_on_window_activation focus
for_window [app_id="fsel"] border pixel 2
for_window [app_id="otter-launcher"] border pixel 2
assign [app_id="dev.zed.Zed"] output DP-1
for_window [app_id="dev.zed.Zed"] focus

# -Key bindings-

# Basics:
    bindsym $mod+Return exec $term
    bindsym $mod+q kill
    bindsym $mod+space exec $menu
    bindsym $mod+d exec $launcher
    floating_modifier $mod normal
    bindsym $mod+Shift+r reload
    bindsym $mod+Shift+e exit

# App launchers:
    bindsym $mod+b exec $browser
    bindsym $mod+e exec $filemanager
    # bindsym $mod+w (wallpaper selector removed - using solid color bg)
    bindsym $mod+p exec kitty --app-id powermenu fish -c powermenu
    bindsym $mod+s exec steam
    bindsym $mod+a exec mumble

# Moving around:
    bindsym $mod+$left focus left
    bindsym $mod+$down focus down
    bindsym $mod+$up focus up
    bindsym $mod+$right focus right
    bindsym $mod+Left focus left
    bindsym $mod+Down focus down
    bindsym $mod+Up focus up
    bindsym $mod+Right focus right

    bindsym $mod+Shift+$left move left
    bindsym $mod+Shift+$down move down
    bindsym $mod+Shift+$up move up
    bindsym $mod+Shift+$right move right
    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:
    bindsym $mod+1 workspace number 1
    bindsym $mod+2 workspace number 2
    bindsym $mod+3 workspace number 3
    bindsym $mod+4 workspace number 4
    bindsym $mod+5 workspace number 5
    bindsym $mod+6 workspace number 6
    bindsym $mod+7 workspace number 7
    bindsym $mod+8 workspace number 8
    bindsym $mod+9 workspace number 9
    bindsym $mod+0 workspace number 10
    bindsym $mod+n workspace number 11
    bindsym $mod+m workspace number 12

# Move window to workspace and follow:
    bindsym $mod+Shift+1 move container to workspace number 1; workspace number 1
    bindsym $mod+Shift+2 move container to workspace number 2; workspace number 2
    bindsym $mod+Shift+3 move container to workspace number 3; workspace number 3
    bindsym $mod+Shift+4 move container to workspace number 4; workspace number 4
    bindsym $mod+Shift+5 move container to workspace number 5; workspace number 5
    bindsym $mod+Shift+6 move container to workspace number 6; workspace number 6
    bindsym $mod+Shift+7 move container to workspace number 7; workspace number 7
    bindsym $mod+Shift+8 move container to workspace number 8; workspace number 8
    bindsym $mod+Shift+9 move container to workspace number 9; workspace number 9
    bindsym $mod+Shift+0 move container to workspace number 10; workspace number 10
    bindsym $mod+Shift+n move container to workspace number 11; workspace number 11
    bindsym $mod+Shift+m move container to workspace number 12; workspace number 12

# Move window silently to workspace:
    bindsym $mod+Ctrl+1 move container to workspace number 1
    bindsym $mod+Ctrl+2 move container to workspace number 2
    bindsym $mod+Ctrl+3 move container to workspace number 3
    bindsym $mod+Ctrl+4 move container to workspace number 4
    bindsym $mod+Ctrl+5 move container to workspace number 5
    bindsym $mod+Ctrl+6 move container to workspace number 6
    bindsym $mod+Ctrl+7 move container to workspace number 7
    bindsym $mod+Ctrl+8 move container to workspace number 8
    bindsym $mod+Ctrl+9 move container to workspace number 9
    bindsym $mod+Ctrl+0 move container to workspace number 10
    bindsym $mod+Ctrl+Left move container to workspace prev; workspace prev
    bindsym $mod+Ctrl+Right move container to workspace next; workspace next

# Workspace cycling:
    bindsym $mod+period workspace next_on_output
    bindsym $mod+comma workspace prev_on_output
    bindsym $mod+slash workspace back_and_forth

# Scratchpad:
    bindsym $mod+minus move scratchpad
    bindsym $mod+equal scratchpad show

# Layout stuff:
    bindsym $mod+Shift+b splith
    bindsym $mod+Shift+v splitv
    bindsym $mod+Shift+s layout stacking
    bindsym $mod+Shift+w layout tabbed
    bindsym $mod+t layout toggle split
    bindsym $mod+f fullscreen
    bindsym $mod+v floating toggle

# Resize mode:
    bindsym $mod+r mode "resize"
    mode "resize" {
        bindsym $left resize shrink width 15px
        bindsym $down resize grow height 15px
        bindsym $up resize shrink height 15px
        bindsym $right resize grow width 15px
        bindsym Left resize shrink width 15px
        bindsym Down resize grow height 15px
        bindsym Up resize shrink height 15px
        bindsym Right resize grow width 15px
        bindsym $mod+Ctrl+Shift+Left resize shrink width 15px
        bindsym $mod+Ctrl+Shift+Down resize grow height 15px
        bindsym $mod+Ctrl+Shift+Up resize shrink height 15px
        bindsym $mod+Ctrl+Shift+Right resize grow width 15px
        bindsym Return mode "default"
        bindsym Escape mode "default"
        bindsym $mod+r mode "default"
    }

# Utilities:
    # Volume
    bindsym --locked XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle
    bindsym --locked XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -5%
    bindsym --locked XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +5%
    bindsym --locked XF86AudioMicMute exec pactl set-source-mute @DEFAULT_SOURCE@ toggle
    # Brightness
    bindsym --locked XF86MonBrightnessDown exec brightnessctl set 5%-
    bindsym --locked XF86MonBrightnessUp exec brightnessctl set 5%+
    # Screenshots
    bindsym Print exec grim -g "$(slurp)" - | wl-copy
    bindsym Shift+Print exec grim - | wl-copy
    bindsym Ctrl+Print exec grim -o $(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .name') - | wl-copy
    # Playback
    bindsym $mod+bracketright exec playerctl --player=spotify_player next
    bindsym $mod+bracketleft exec playerctl --player=spotify_player previous
    bindsym $mod+backslash exec playerctl --player=spotify_player play-pause
    bindsym XF86AudioPlay exec playerctl play-pause
    bindsym XF86AudioNext exec playerctl next
    bindsym XF86AudioPrev exec playerctl previous

include @sysconfdir@/sway/config.d/*
